| 97 | */ |
| 98 | |
| 99 | ipp_t * /* O - Response data */ |
| 100 | cupsDoIORequest(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 | } |
no test coverage detected