CAPS Universe documentation
1.0.4
All you need to know to be successful
|
Process printing parameters and configure a printing job. More...
Data Structures | |
struct | option_function_relation |
Printing parameter keywords and their corresponding handler function. More... | |
Macros | |
#define | DEFAULT_ENABLE 1 |
#define | DEFAULT_DISABLE 0 |
Functions | |
static bool | string_is_valid (const char *str) |
static void | add_range_entry (struct caps_var_table *tab, unsigned start, unsigned stop) |
static void | ensure_one_page_range (struct caps_var_table *tab) |
static int | range_compare (const void *restrict p1, const void *restrict p2) |
static void | sort_range_list (struct caps_var_table *tab) |
static void | move_range_entries (struct doc_page_range_entry *to, const struct doc_page_range_entry *from, size_t cnt) |
static void | merge_range_list (struct caps_var_table *tab) |
static int | ipp_get_fidelity_value (struct document_desc *job, const char *value) |
static void | remove_whitespaces (char *value) |
static int | ipp_get_page_range_value (struct document_desc *job, const char *string) |
static int | caps_ppd_handle_media_value (struct document_desc *job, const char *value) |
static int | ipp_get_orientation_value (struct document_desc *job, const char *value) |
static int | ipp_get_copies_value (struct document_desc *job, const char *value) |
static int | ipp_get_document_value (struct document_desc *job, const char *type) |
static int | ipp_get_collate_value (struct document_desc *job, const char *value) |
static int | ipp_get_quality_value (struct document_desc *job, const char *value) |
static int | ipp_get_resolution_value (struct document_desc *job, const char *value) |
static int | ipp_get_sides_value (struct document_desc *job, const char *value) |
static int | ipp_page_fit_positive (struct document_desc *job, const char *value) |
static int | ipp_page_fit_negative (struct document_desc *job, const char *value) |
static int | ipp_auto_fit (struct document_desc *job, const char *value) |
static int | ipp_crop_fit (struct document_desc *job, const char *value) |
static int | ipp_scale_fit (struct document_desc *job, const char *value) |
static int | fit_rotate (struct document_desc *job, const char *value) |
static int | align_left (struct document_desc *job, const char *value) |
static int | align_right (struct document_desc *job, const char *value) |
static int | align_top (struct document_desc *job, const char *value) |
static int | align_bottom (struct document_desc *job, const char *value) |
static int | handle_ipp_parameter (struct document_desc *job, const char *keyword, const char *value) |
static char * | replace_string (char *current, const char *string) |
static int | handle_special_ppd_parameter (struct document_desc *job, const char *keyword, const char *value) |
static int | handle_ppd_parameter (struct document_desc *job, const char *keyword, const char *value) |
static int | process_job_parameter (struct document_desc *job, const char *pparams) |
static void | job_printing_defaults_log (const struct document_desc *job) |
static void | job_printing_resolution_defaults (struct document_desc *job) |
static void | job_printing_defaults_init (struct document_desc *job) |
struct document_desc * | job_create (int fd, struct caps_ppd_options_table *ppd_options, const char *params) |
void | job_destroy (struct document_desc *job) |
Variables | |
static const struct option_function_relation | supported_ipp_options [] |
static const struct caps_table_desc | page_range_table_desc |
The so called printing parameters are a list of keyword/value pairs (some are of type boolean and may not have a value). Some of the keywords and their values correspond to the content of the PPD file and other keywords and their values are from the IPP universe.
The PPD file corresponding keywords and their values are given, if the user selects a different PPD setting than the default one. If the user doesn't change the defaults, its setting is implicit and doesn't need a reference in the printing parameters.
The IPP related printing parameter keyword/value pairs aren't related to the PPD, they handle common printing options instead. Defining the amount of copies to print is an example here.
Printing command line example:
sides=two-sided-long-edge copies=2 ColorModel=Mono Duplex=DuplexNoTumble
Read the full description in Supported Printing Parameter.
#define DEFAULT_ENABLE 1 |
#define DEFAULT_DISABLE 0 |
|
static |
Check a parameter's value if it is a valid string
[in] | str | String to check |
true | Yes, it is a valid string |
false | No, its invalid or empty |
A valid string must have a valid pointer (e.g. not NULL) and it must contain at least one valid character.
str
looks like a duck
|
static |
[in,out] | tab | Dynamic table to add an entry to |
[in] | start | First page to print in this range |
[in] | stop | Last page to prinit in this range |
start
< stop
, else stop
== 0
|
static |
Ensure at least one page-range entry is available covering the whole document
[in,out] | tab | The page-range table to check |
Maybe the client hasn't defined any page range, which means "print the whole document", but the page_range_info array is empty in this case - which would mean "print nothing from the document".
Thus, if the page_range_info array is empty, provide at least one element: for the full document: 1 … UINT_MAX.
|
static |
Simple compare function for page ranges to be sorted by qsort
[in] | p1 | Page range entry #1 to compare against p2 |
[in] | p2 | Page range entry #2 to compare against p1 |
'-1' | if p1 < p2 |
'0' | if p1 == p2 |
'1' | if p1 > p2 |
|
static |
Sort the given page range list
[in] | tab | The page range list to sort |
This sorts the given list of page ranges from the beginning (e.g. page one) to the highest page.
range #1 |---------| range #2 |-----| result: kept range #1 |-----| range #2 |---------| result: range #1 |---------| range #2 |-----| --> the lower 'first' comes earlier in the list range #1 |-----| range #2 |---------| result: range #1 |---------| range #2 |-----| --> the lower 'first' comes earlier in the list
|
static |
|
static |
Merge overlapping page range entries into one page range entry
[in] | tab | The page range list to sort |
Merging is required for easier duplex printing support.
Case #1: range #1 |---------| range #2 |-----| result: kept Case #2: range #1 |---------| range #2 |-----| (note same page twice) result: |---------------| Case #3: range #1 |---------| range #2 |----| (note consecutive page) result: |---------------| Case #4: range #1 |---------| range #2 |-----| result: |------------| Case #5: -> like case #1 with range #1 up to UINT_MAX range #1 |---------| range #2 |-----| result: |---------| Case #6: -> like case #5 range #1 |---------| range #2 |-----| result: |---------| Case #7: -> like case #4 range #1 |---------| range #2 |------------| result: |------------| Case #8: -> like case #5 range #1 |---------| range #2 |-----| result: |---------|
|
static |
Get the IPP ipp-attribute-fidelity
command line parameter's value
[in,out] | job | The job information to adapt |
[in] | value | Keyword's value |
The given option is of the form ipp-attribute-fidelity=<bool>
The short form ipp-attribute-fidelity
is also accepted as true
|
static |
ipp_get_page_range_value() cannot deal with whitespaces, so remove them
[in,out] | value | The string to remove all whitespaces from |
Removement happen in-place. This will shorten the string.
|
static |
Get the IPP page-ranges
command line parameter's value
[in,out] | job | The job information to adapt |
[in] | string | Keyword's value (can be NULL) |
0 | On success |
-EINVAL | string is invalid, e.g. NULL or empty or contains all kind of invalid values |
The given option is of the form page-ranges=string
Values for string:
number
-> prints a single pagenumber-
-> print begins with page <number>
up to the last page-number
-> prints from the first page up to page <number>
number1-number2
-> print begins with page <number1>
up to page <number2>
1-4,7,9-12
Handling of the page-ranges isn't trivial. What does the client means if he offers the string "7-8,2-3,6-7,3-4". Does he want us to really print in that order, or can we sort and re-arange the list?
Currently the list gets sorted and re-aranged here. Thus, the string "7-8,2-3,6-7,3-4" results into the printing page order 2,3,4,6,7,8
|
static |
Handle the IPP media
command line option's value
[in,out] | job | The job information to adapt |
[in] | value | Keyword's value |
The given option is of the form media=<medium-name>,<medium-size>,<input-tray>
values for <medium-name>
: IPP reference
values for <medium-size>
: IPP reference
values for <input-tray>
:
top:
The top input tray in the printer.middle:
The middle input tray in the printer.bottom:
The bottom input tray in the printer.envelope:
The envelope input tray in the printer.manual:
The manual feed input tray in the printer.large-capacity
: The large capacity input tray in the printer.main:
The main input trayside:
The side input trayThese entries are used, when no 'PageSize', 'MediaType' or 'InputSlot' are given. Or to be more precise: they can be overwritten.
|
static |
Get the IPP "orientation-requested" setting
[in,out] | job | The job information to adapt |
[in] | value | Keyword's value |
The given parameter is of the form orientation-requested=<orientation>
If the parameter "landscape" is given it has precedence (TODO Why?)
values for <orientation>
are:
3
- portrait
, e.g. 'No rotation' if the medium is printed in portrait4
- landscape
, e.g. '90 degrees counter-clockwise' if the medium is printed in portrait5
- reverse-landscape
, e.g. '90 degrees clockwise' if the medium is printed in portrait6
- reverse-portrait
, e.g. '180 degrees' if the medium is printed in portraitThe original description:
Value Symbolic Name and Description
'3' 'portrait': The content will be imaged across the short edge of the medium.
'4' 'landscape': The content will be imaged across the long edge of the medium. Landscape is defined to be a rotation of the print-stream page to be imaged by +90 degrees with respect to the medium (i.e. anti-clockwise) from the portrait orientation. Note: The +90 direction was chosen because simple finishing on the long edge is the same edge whether portrait or landscape
'5' 'reverse-landscape': The content will be imaged across the long edge of the medium. Reverse-landscape is defined to be a rotation of the print-stream page to be imaged by - 90 degrees with respect to the medium (i.e. clockwise) from the portrait orientation. Note: The 'reverse- landscape' value was added because some applications rotate landscape -90 degrees from portrait, rather than +90 degrees.
'6' 'reverse-portrait': The content will be imaged across the short edge of the medium. Reverse-portrait is defined to be a rotation of the print-stream page to be imaged by 180 degrees with respect to the medium from the portrait orientation. Note: The 'reverse-portrait' value was added for use with the "finishings" attribute in cases where the opposite edge is desired for finishing a portrait document on simple finishing devices that have only one finishing position. Thus a 'text'/plain' portrait document can be stapled "on the right" by a simple finishing device as is common use with some middle eastern languages such as Hebrew.
|
static |
Handle the IPP copies
parameter
[in,out] | job | The job information to adapt |
[in] | value | Keyword's value |
0 | On success |
-EINVAL | Parameter without a value or invalid value |
This option needs to be given if the default of '1' isn't satisfying...
|
static |
Handle the IPP multiple-document-handling
option
[in,out] | job | The job information to adapt |
[in] | type | Keyword's value |
0 | On success |
-EINVAL | Paramter without a value or with an unknown value |
The given option is of the form multiple-document-handling=type
Values for type
are:
single-document
separate-documents-uncollated-copies
separate-documents-collated-copies
single-document-new-sheet
|
static |
Handle the CUPS boolean collate
parameter
[in,out] | job | The job information to adapt |
[in] | value | Keyword's value |
The given option is of the form collate=<bool>
The short form collate
is also accepted as true
multiple-document-handling
and overwrites its setting, refer ipp_get_document_value() for details
|
static |
Get the IPP print-quality
parameter
[in,out] | job | The job information to adapt |
[in] | value | Keyword's value |
The given option is of the form print-quality=<quality>
values for <quality> are
|
static |
Get the IPP printer-resolution
command line value
[in,out] | job | The job information to adapt |
[in] | value | Keyword's value |
The given option is of the form printer-resolution=<resolution>
. (or resolution=<resolution>
)
Value for <resolution> is of three values:
Example:
printer-resolution=2400x600DPI
printer-resolution=600DPI
printer-resolution=600
(unit 'dots per inch' is the default)
|
static |
Handle the IPP sides
parameter
[in,out] | job | The job information to adapt |
[in] | value | Keyword's value |
0 | On success |
-EINVAL | Parameter without a value or invalid value |
The given parameter is of the form sides=<type>
Supported values of <type>
are:
one-sided
: simplextwo-sided-long-edge
: duplex at long edgetwo-sided-short-edge
: duplex at short edge
|
static |
Handle fitting parameter fitplot
and fit-to-page
[in,out] | job | The job information to adapt |
[in] | value | Keyword's value |
What does pdftopdf
do? "Scale to fit printable area"
|
static |
Handle non-fitting parameter nofitplot
and nofit-to-page
[in,out] | job | The job information to adapt |
[in] | value | Keyword's value |
nofitplot
is a depricated keywordWhat does a nofitplot=false mean?
What does a nofitplot=true mean?
no fitplot (switch this feature off)
|
static |
Handle automatic fitting parameter auto-fit
[in,out] | job | The job information to adapt |
[in] | value | Keyword's value |
|
static |
Handle crop fitting parameter crop-to-fit
[in,out] | job | The job information to adapt |
[in] | value | Keyword's value |
Maybe ipp_page_fit_negative() can be re-used here
What is the user's expectation if he sets crop-to-fit=false ?
|
static |
Handle automatic scale fitting parameter scale-to-fit
[in,out] | job | The job information to adapt |
[in] | value | Keyword's value |
Maybe ipp_page_fit_positive() can be re-used here
What is the user's expectation if he sets scale-to-fit=false ?
|
static |
[in,out] | job | The job information to adapt |
[in] | value | Keyword's value |
|
static |
Handle alignment of the document on a larger medium. Here: align-left
[in,out] | job | The job information to adapt |
[in] | value | Keyword's value |
|
static |
Handle alignment of the document on a larger medium. Here: align-right
[in,out] | job | The job information to adapt |
[in] | value | Keyword's value |
|
static |
Handle alignment of the document on a larger medium. Here: align-top
[in,out] | job | The job information to adapt |
[in] | value | Keyword's value |
|
static |
Handle alignment of the document on a larger medium. Here: align-bottom
[in,out] | job | The job information to adapt |
[in] | value | Keyword's value |
|
static |
Handle IPP specific, but generic parameters
[in,out] | job | The printing job to manipulate |
[in] | keyword | The parameter keyword to process (might be not an IPP related parameter) |
[in] | value | The parameter keyword's value (might be NULL for boolean IPP parameters) |
0 | If successfully handled |
-ENOTSUP | If the keyword is unknown |
-errno | From the handler functions, if the parameter is somehow invalid |
The PPD file corresponding keywords are ignored here and a -ENOTSUP is returned to inform the caller to continue handling of this keyword in a different (e.g. PPD related) way.
|
static |
Replace a dynamic string if they differ
[in] | current | Current memory allocated with malloc (can be NULL) |
[in] | string | The new string to allocate (can be NULL) |
string
== NULL)
|
static |
Handle special PPD entries generated by libcapsppd
[in,out] | job | The job to apply parameters to |
[in] | keyword | PPD keyword to change |
[in] | value | Keyword's new value, content is volatile |
0 | The keyword was successfully processed |
-ENOTSUP | The keyword isn't one of the special ones |
Deal with a few PPD related entries, which are not part of the PPD option list in a generic manner. These kind of entries define some generic print parameter and thus, have only a Default* entry, but not their corresponding value entries. That's why they cannot be handled in handle_ppd_parameter().
PPD parameters handled here:
PageSize:
Only DefaultPageSize
, ImageableArea
and PaperDimension
are presentLeadingEdge:
Only DefaultLeadingEdge
is presentResolution:
Only DefaultResolution
is presentColorModel:
Only DefaultColorModel
is presentDuplex:
With a parameter like the 'sides' IPP parameterSome PPD entries require special treatment. They are generated in libcapsppd due to some entries in caps_ppd_base
|
static |
Adapt the printing driver defaults from the PPD in accordance to the parameters
[in,out] | job | The job to apply parameters to |
[in] | keyword | PPD keyword to change |
[in] | value | Keyword's new value (one of the PPD's 'name' entries), content is volatile, can be NULL |
We cannot expect a fixed count of keywords here, due to the fact we create the PPD content by our own. Instead a printing provider can add as much new keywords as required to do its job.
For example. A PPD contains the following entries:
keyword | name |
---|---|
DefaultResolution | 1200x600dpi |
Resolution | 300dpi |
Resolution | 600dpi |
Resolution | 1200x600dpi |
A corresponding parameter's value is limited to one of the available Resolution
entries (e.g. 300dpi
, 600dpi
or 1200x600dpi
).
In this example the 1200x600dpi
value is already selected (e.g. the default). Most clients do not overwrite the default. They only add the Resolution
keyword, if a different value than the default was selected by the user. In the example above we would receive here a Resolution=300dpi
or Resolution=600dpi
.
Other values than the defined ones are ignored here.
name
components must be part of the ppd_list
. E.g. to change the DefaultPageSize, all possible names
must be listed in the form PageSize=<name> This is required in order to validate the new name
component.
|
static |
Spread the printing parameters into various structures
[in,out] | job | The job to apply parameters to |
[in] | pparams | The job parameters (if any, e.g. can be NULL) |
0 | On success |
Negative | Errno value else |
The printing parameters are a list of key/value pairs. Some are 'standalone' pairs (defining the copy count for example, IPP related) and some are meant in conjunction with the PPD and its content (to overwrite their defaults). Process this list and store the result into the structure members.
An example for printing parameters could be:
"TonerDensity=1 copies=1 orientation-requested=3 ColorModel=Mono"
|
static |
Just log the current job's printing parameter settings
[in] | job | The job settings to log |
|
static |
|
static |
Setup the printing option defaults every print job should begin with
[in,out] | job | The job to init |
This is a separate function for documentation reasons and its settings must correspond with the documented behaviour.
struct document_desc * job_create | ( | int | fd, |
struct caps_ppd_options_table * | ppd_options, | ||
const char * | params | ||
) |
Create a new job data collection
[in] | fd | The documents file descriptor for reading |
[in] | ppd_options | The job's corresponding default PPD settings |
[in] | params | The print parameter (can be NULL) |
Pointer | A pointer to a dynamic job data collection structure |
Creates a job and pre-process the ppd_options
and params
.
ppd_options
table will be freed by job_destroy() void job_destroy | ( | struct document_desc * | job | ) |
Free job related data
[in] | job | The job data collection to destroy |
Frees the related resources and closes the document related file descriptor on demand
|
static |
Printing parameter keywords and their corresponding handler function
|
static |