tailieunhanh - Common UNIX Printing System Sweet phần 6

Thư viện tách được cung cấp theo LGPL để cung cấp sự linh hoạt nhất khi phát triển và phân phối phần mềm. Các thư viện cupsimage được cung cấp theo GPL và yêu cầu phần mềm bằng cách sử dụng thư viện để được phân phối theo GPL. | previous page page_299 next page Page 299 The cupsDoFileRequest also accepts a filename string to specify a file to send to the server after the IPP data. Both functions return a pointer to the IPP object holding the response from the server. If an error occurs NULL is returned and the IPP error code can be found by calling the cupsLastError function. One advantage of using these functions over your own code is that common errors such as missing the 0-length block handling code are avoided. These functions also support authentication using the password callback mechanism described in Chapter 14. This allows your application to fully utilize all authentication encryption and error-checking mechanisms without duplicating code. Building a Real IPP Request Now that you know the basics you will write a new program that sends a CUPS-Get-Printers request to list all of the available printers on the server. To begin create the IPP request object ipp_t request . request ippNew Next add the required attributes for the request for CUPS-Get-Printers you must send attributes-charset and attributes-natural-language attributes ippAddString request IPP_TAG_OPERATION IPP_TAG_CHARSET _ attributes-charset NULL utf-8 ippAddString request IPP_TAG_OPERATION IPP_TAG_LANGUAGE attributes-natural-language NULL fen Then initialize theIPP requestheader by setting the and fields to CUPS_GET_PRINTERS and 1 respectively request- CUPS_GET_PRINTERS request- 1 Finally send the request using cupsDoRequest ipp_t response http_t http . response cupsDoRequest http request After you have the response you can use ippFindAttribute and ippFindNextAttribute to show the names of the printers ipp_attribute_t attr . previous page page_299 next page previous page page_300 next page Page 300 for attr ippFindAttribute ipp printer-name IPP_TAG_NAME attr NULL attr ippFindNextAttribute ipp printer-name IPP_TaG_NAME puts .

TỪ KHÓA LIÊN QUAN