| 5410 | */ |
| 5411 | |
| 5412 | static int /* O - 1 on success, 0 on failure */ |
| 5413 | cups_get_url(http_t **http, /* IO - Current HTTP connection */ |
| 5414 | const char *url, /* I - URL to get */ |
| 5415 | char *name, /* I - Temporary filename */ |
| 5416 | size_t namesize) /* I - Size of temporary filename buffer */ |
| 5417 | { |
| 5418 | char resource[256]; /* URL resource */ |
| 5419 | http_status_t status; /* Status of GET request */ |
| 5420 | int fd; /* Temporary file */ |
| 5421 | |
| 5422 | |
| 5423 | if (!cups_connect(http, url, resource, sizeof(resource))) |
| 5424 | return (0); |
| 5425 | |
| 5426 | if ((fd = cupsTempFd(name, (int)namesize)) < 0) |
| 5427 | return (0); |
| 5428 | |
| 5429 | status = cupsGetFd(*http, resource, fd); |
| 5430 | |
| 5431 | close(fd); |
| 5432 | |
| 5433 | if (status != HTTP_STATUS_OK) |
| 5434 | { |
| 5435 | unlink(name); |
| 5436 | *name = '\0'; |
| 5437 | return (0); |
| 5438 | } |
| 5439 | |
| 5440 | return (1); |
| 5441 | } |
| 5442 | |
| 5443 | |
| 5444 | /* |
no test coverage detected