-
Notifications
You must be signed in to change notification settings - Fork 270
Closed
Description
Hello
I use cupsSendRequest to get printer status information. After successfully calling cupsGetResponse, should I immediately delete the request object with ippDelete? If I read the response attributes first and then call ippDelete in sequence, will there be any issues?
This is my code:
ipp_t *request = NULL;
ipp_t *response = NULL;
http_status_t result;
request = ippNewRequest(op);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, printer_uri);
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes",
sizeof(pattrs) / sizeof(pattrs[0]), NULL, pattrs);
do {
result = cupsSendRequest(http, request, resource, ippLength(request));
if (result <= HTTP_STATUS_CONTINUE || result == HTTP_STATUS_OK) {
response = cupsGetResponse(http, resource);
result = httpGetStatus(http);
}
if (result == HTTP_STATUS_ERROR || (result >= HTTP_STATUS_BAD_REQUEST &&
result != HTTP_STATUS_UNAUTHORIZED && result != HTTP_STATUS_UPGRADE_REQUIRED)) {
_cupsSetHTTPError(result);
break;
}
if (http->state != HTTP_STATE_WAITING) {
httpFlush(http);
}
} while (response == NULL);
if (response && (attrptr = ippFindAttribute(response, "printer-state", IPP_TAG_ENUM)) != NULL) {
printer_ippstate = (ipp_pstate_t) ippGetInteger(attrptr, 0);
}
ippDelete(request);
ippDelete(response);
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels