| 516 | */ |
| 517 | |
| 518 | http_status_t /* O - HTTP status */ |
| 519 | cupsPutFile(http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */ |
| 520 | const char *resource, /* I - Resource name */ |
| 521 | const char *filename) /* I - Filename */ |
| 522 | { |
| 523 | int fd; /* File descriptor */ |
| 524 | http_status_t status; /* Status */ |
| 525 | |
| 526 | |
| 527 | /* |
| 528 | * Range check input... |
| 529 | */ |
| 530 | |
| 531 | if (!http || !resource || !filename) |
| 532 | { |
| 533 | if (http) |
| 534 | http->error = EINVAL; |
| 535 | |
| 536 | return (HTTP_STATUS_ERROR); |
| 537 | } |
| 538 | |
| 539 | /* |
| 540 | * Open the local file... |
| 541 | */ |
| 542 | |
| 543 | if ((fd = open(filename, O_RDONLY)) < 0) |
| 544 | { |
| 545 | /* |
| 546 | * Couldn't open the file! |
| 547 | */ |
| 548 | |
| 549 | http->error = errno; |
| 550 | |
| 551 | return (HTTP_STATUS_ERROR); |
| 552 | } |
| 553 | |
| 554 | /* |
| 555 | * Put the file... |
| 556 | */ |
| 557 | |
| 558 | status = cupsPutFd(http, resource, fd); |
| 559 | |
| 560 | close(fd); |
| 561 | |
| 562 | return (status); |
| 563 | } |
no test coverage detected