![]() |
CAPS Universe documentation
1.0.4
All you need to know to be successful
|
Some helper functions to iterate over all to be printed pages of a document. More...
Functions | |
| static void | print_page_range_error (const struct doc_page_range_entry *pr, unsigned max_page) |
| static unsigned | page_predict_next (struct doc_range_list *list, unsigned page, unsigned last_page, int check) |
| unsigned | job_page_get_next (struct document_desc *job, unsigned cpage) |
| unsigned | job_page_count_calculate (struct document_desc *job, unsigned pgs) |
Some helper functions to iterate over all to be printed pages of a document. And they are part of this separate source file to simplify their testing.
|
static |
|
static |
Return the next to be printed page number beginning at page
| [in] | list | Page range list to search in |
| [in] | page | The start to find its next page number (can be '0' which means search the first page to print) |
| [in] | last_page | The number of the last page in the document (1…) |
| [in] | check | 0 for next page calc, non 0 for check (to suppress to many error messages) |
| Number | The next page number to print |
| 0 | If page is the last one in the list of page ranges or the next page exceeds last_page |
The number returned is in the list of page ranges. Expect a forth and back jumping returned page number if the page ranges are not sorted (e.g. "19-,3-8,15,12-13").
page = '0' in order to initialize the doc_range_list::iterator page must be valid, e.g. member in one of the page ranges (except '0'). If not, it crashes. -— What? page must be smaller than or equal to last_page last_page must be '1…INT_MAX' (e.g. not '0') | unsigned job_page_get_next | ( | struct document_desc * | job, |
| unsigned | cpage | ||
| ) |
Move to the next to be printed page in the document according to the existing page ranges
| [in,out] | job | The information collection about the job |
| [in] | cpage | Current page (or: last already printed page, e.g. page from the last call), 0 … UINT_MAX |
| Number | The number of the next to be printed page |
| 0 | If there are no more pages in the document to print |
The page value of 0 has a special meaning: this returns the first to be printed page in the document.
In order to step through the document, start with page = 0, and continue to call this function with the returned value of the last call.
| unsigned job_page_count_calculate | ( | struct document_desc * | job, |
| unsigned | pgs | ||
| ) |
Calculate the amount of to be printed pages from the document in one turn
| [in,out] | job | The information collection about the job |
| [in] | pgs | The document's last page number |
| Positive | Amount of to be printed pages |
| '0' | Nothing to print |
If a full page range is given and the document has 10 pages, the calculation is simple. But if pages ranges are given and they restrict the pages to be printed, a real calculation is required.