MCPcopy Create free account
hub / github.com/OpenPrinting/cups / cupsStartDocument

Function cupsStartDocument

cups/util.c:903–954  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

901 */
902
903http_status_t /* O - HTTP status of request */
904cupsStartDocument(
905 http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
906 const char *name, /* I - Destination name */
907 int job_id, /* I - Job ID from @link cupsCreateJob@ */
908 const char *docname, /* I - Name of document */
909 const char *format, /* I - MIME type or @code CUPS_FORMAT_foo@ */
910 int last_document) /* I - 1 for last document in job, 0 otherwise */
911{
912 char resource[1024], /* Resource for destination */
913 printer_uri[1024]; /* Printer URI */
914 ipp_t *request; /* Send-Document request */
915 http_status_t status; /* HTTP status */
916
917
918 /*
919 * Create a Send-Document request...
920 */
921
922 if ((request = ippNewRequest(IPP_OP_SEND_DOCUMENT)) == NULL)
923 {
924 _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(ENOMEM), 0);
925 return (HTTP_STATUS_ERROR);
926 }
927
928 httpAssembleURIf(HTTP_URI_CODING_ALL, printer_uri, sizeof(printer_uri), "ipp",
929 NULL, "localhost", ippPort(), "/printers/%s", name);
930 snprintf(resource, sizeof(resource), "/printers/%s", name);
931
932 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
933 NULL, printer_uri);
934 ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id", job_id);
935 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
936 NULL, cupsUser());
937 if (docname)
938 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "document-name",
939 NULL, docname);
940 if (format)
941 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_MIMETYPE,
942 "document-format", NULL, format);
943 ippAddBoolean(request, IPP_TAG_OPERATION, "last-document", (char)last_document);
944
945 /*
946 * Send and delete the request, then return the status...
947 */
948
949 status = cupsSendRequest(http, request, resource, CUPS_LENGTH_VARIABLE);
950
951 ippDelete(request);
952
953 return (status);
954}
955

Callers 5

mainFunction · 0.85
cgiPrintCommandFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
cupsPrintFiles2Function · 0.85

Calls 10

ippNewRequestFunction · 0.85
_cupsSetErrorFunction · 0.85
httpAssembleURIfFunction · 0.85
ippPortFunction · 0.85
ippAddStringFunction · 0.85
ippAddIntegerFunction · 0.85
cupsUserFunction · 0.85
ippAddBooleanFunction · 0.85
cupsSendRequestFunction · 0.85
ippDeleteFunction · 0.85

Tested by 1

mainFunction · 0.68