mirror of
https://gitee.com/openharmony/third_party_cups
synced 2024-11-26 19:40:32 +00:00
f7b65a020f
Merge pull request !49 from yyc1234/master |
||
---|---|---|
backport-Also-fix-cupsfilter.patch | ||
backport-CVE-2022-26691.patch | ||
backport-CVE-2023-4504.patch | ||
backport-CVE-2023-32324.patch | ||
backport-CVE-2023-34241.patch | ||
backport-CVE-2024-35235.patch | ||
backport-Remove-legacy-code-for-RIP_MAX_CACHE-environment-variable.patch | ||
BUILD.gn | ||
bundle.json | ||
config.h | ||
cups-2.4.0-source.tar.gz | ||
cups-banners.patch | ||
cups-direct-usb.patch | ||
cups-driverd-timeout.patch | ||
cups-freebind.patch | ||
cups-ipp-multifile.patch | ||
cups-multilib.patch | ||
cups-system-auth.patch | ||
cups-uri-compat.patch | ||
cups-usb-paperout.patch | ||
cups-web-devices-timeout.patch | ||
cups.gni | ||
cups.spec | ||
cups.yaml | ||
cupsprinter.png | ||
fix-httpAddrGetList-test-case-fail.patch | ||
generate_mime_convs.py | ||
install.py | ||
LICENSE | ||
OAT.xml | ||
ohos_ip_conflict.patch | ||
ohos-add-openssl.patch | ||
ohos-modify-pthread.patch | ||
ohos-multi-file-print.patch | ||
ohos-ppdfile-not-generated.patch | ||
ohos-usb-manager.patch | ||
ohos-usb-print.patch | ||
README_zh.md | ||
README.md | ||
README.OpenSource |
CUPS
Introduction
OpenPrinting CUPS is the most current version of CUPS, a standards-based, open source printing system for Linux® and other Unix®-like operating systems. CUPS supports printing to:
- AirPrint™ and IPP Everywhere™ printers,
- Network and local (USB) printers with Printer Applications, and
- Network and local (USB) printers with (legacy) PPD-based printer drivers.
You can also learn more about the CUPS project through the official website
Background Brief
In the process of OpenHarmony's southward ecological development, it is necessary to be compatible with printers in the stock market. The use of CUPS printing system can directly connect with most printers in the market, which also reduces the difficulty for printer manufacturers to adapt to OpenHarmony.
How to use
1、Header file import
#include <cups/cups-private.h>
2、Add Compilation Dependency
Add in the bundle. json file
"deps": {
"third_part": [
"cups"
]
}
Add dependencies where needed in BUILD.gn
deps += [ "//third_party/cups:cups" ]
3、Example of interface usage
// Example of using CUPS interface to query printer capabilities
ipp_t *request; /* IPP Request */
ipp_t *response; /* IPP response */
http_t *http = NULL;
char scheme[HTTP_MAX_URI]; // Protocol
char username[HTTP_MAX_URI];
char host[HTTP_MAX_URI];
int port;
// Declare which printer capabilities need to be queried, here are all
static const char * const pattrs[] = {
"all"
};
// Connect to printer
http = httpConnect2(host, port, NULL, AF_UNSPEC, HTTP_ENCRYPTION_IF_REQUESTED, 1, TIME_OUT, NULL);
if (http == nullptr) {
return;
}
request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, printerUri.c_str());
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes",
(int)(sizeof(pattrs) / sizeof(pattrs[0])), NULL, pattrs);
response = cupsDoRequest(http, request, "/");
// parse response
if (cupsLastError() > IPP_STATUS_OK_CONFLICTING) {
ippDelete(response);
return;
}
// close http
httpClose(http);