-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DNS-SD device URI resolution: Cleaned API for upcoming libcups3 support
For resolving DNS-SD-service-name-based device URIs for IPP printers as CUPS uses them, libcups2 does not offer any useful API and we therefore ended up implementing 2 workarounds. One (cfResolveURI()) is using cupsBackendDeviceURI() but this function is focused on use in CUPS backends, so we needed to use special tricks to use it in a general library function, once redirecting stderr, to eliminate log messages sent directly to stderr, and second, temporarily unsetting the DEVICE_URI and PPD environment variables, ro assure that the URI supplied to our function gets resolved and that the resulting hostname/resource-based URI is always for the printing and not for the fax part of the destination device. The other (cfResolveURI2()) is calling `ippfind` as external executable to poll the printer's DNS-SD record which contains all components for the desired hostname/resource-based URI. libcups3 now has added the new function httpResolveURI() to its API, a function which formerly was library-internal, and does exactly what we want, and without getting influenced by environment variables, not polluting stderr, and with easy selection whether a print or fax URI should be returned. So with this commit we have adapted our API (and also slightly the code) in praparation for the transition to libcups3 where we do all DNS-SD device URI resolution with httpResolveURI(), no external executable call or "abuse΅ of functions designed for other purposes. We have - Renamed cfippfindBasedURIConverter() to cfResolveURI2() to not have a mis-leading name and have two functions, cfResolveURI() for print URIs only and cfResolveURI2() to choose between print and fax URI. - In the declaration of cfGetPrinterAttributes5() renamed the last parameter to is_fax, set to 1, we poll the fax part of the device, otherwise the print part. - Let cfResolveURI2() only resolve the fax URI if is_fax is 1, and the print URI on any other value (0 and especially also the formerly used -1). - Let cfResolveURI() also temporarily uset the PPD environment variable, so that cupsBackendDeviceURI() always returns the print URI. This way the behavior of libcupsfilters will be the same for both libcups2 and libcups3.
- Loading branch information
1 parent
6007f6f
commit 54e1adc
Showing
2 changed files
with
38 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters