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

Function cupsDoIORequest

cups/request.c:99–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97 */
98
99ipp_t * /* O - Response data */
100cupsDoIORequest(http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
101 ipp_t *request, /* I - IPP request */
102 const char *resource, /* I - HTTP resource for POST */
103 int infile, /* I - File to read from or -1 for none */
104 int outfile) /* I - File to write to or -1 for none */
105{
106 ipp_t *response = NULL; /* IPP response data */
107 size_t length = 0; /* Content-Length value */
108 http_status_t status; /* Status of HTTP request */
109 struct stat fileinfo; /* File information */
110 ssize_t bytes; /* Number of bytes read/written */
111 char buffer[32768]; /* Output buffer */
112
113
114 DEBUG_printf(("cupsDoIORequest(http=%p, request=%p(%s), resource=\"%s\", infile=%d, outfile=%d)", (void *)http, (void *)request, request ? ippOpString(request->request.op.operation_id) : "?", resource, infile, outfile));
115
116 /*
117 * Range check input...
118 */
119
120 if (!request || !resource)
121 {
122 ippDelete(request);
123
124 _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
125
126 return (NULL);
127 }
128
129 /*
130 * Get the default connection as needed...
131 */
132
133 if (!http && (http = _cupsConnect()) == NULL)
134 {
135 ippDelete(request);
136
137 return (NULL);
138 }
139
140 /*
141 * See if we have a file to send...
142 */
143
144 if (infile >= 0)
145 {
146 if (fstat(infile, &fileinfo))
147 {
148 /*
149 * Can't get file information!
150 */
151
152 _cupsSetError(errno == EBADF ? IPP_STATUS_ERROR_NOT_FOUND : IPP_STATUS_ERROR_NOT_AUTHORIZED, NULL, 0);
153 ippDelete(request);
154
155 return (NULL);
156 }

Callers 4

get_job_fileFunction · 0.85
cupsGetServerPPDFunction · 0.85
cupsDoFileRequestFunction · 0.85
cupsDoRequestFunction · 0.85

Calls 13

ippOpStringFunction · 0.85
ippDeleteFunction · 0.85
_cupsSetErrorFunction · 0.85
_cupsConnectFunction · 0.85
ippLengthFunction · 0.85
httpSetAuthStringFunction · 0.85
cupsSendRequestFunction · 0.85
cupsWriteRequestDataFunction · 0.85
cupsGetResponseFunction · 0.85
httpGetStatusFunction · 0.85
_cupsSetHTTPErrorFunction · 0.85
httpRead2Function · 0.85

Tested by

no test coverage detected