diff options
Diffstat (limited to 'backend/ipp.c')
-rw-r--r-- | backend/ipp.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/backend/ipp.c b/backend/ipp.c index fa0694c03..f71d6186c 100644 --- a/backend/ipp.c +++ b/backend/ipp.c @@ -412,12 +412,22 @@ main(int argc, /* I - Number of command-line args */ * Copy stdin to a temporary file... */ - int fd; /* File descriptor */ - char buffer[8192]; /* Buffer for copying */ - int bytes; /* Number of bytes read */ - off_t tbytes; /* Total bytes copied */ + int fd; /* File descriptor */ + http_addrlist_t *addrlist; /* Address list */ + char buffer[8192]; /* Buffer for copying */ + int bytes; /* Number of bytes read */ + off_t tbytes; /* Total bytes copied */ + if ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, "1")) == NULL) + { + _cupsLangPrintf(stderr, _("ERROR: Unable to locate printer \'%s\'!\n"), + hostname); + return (CUPS_BACKEND_STOP); + } + + snmp_fd = _cupsSNMPOpen(addrlist->addr.addr.sa_family); + if ((fd = cupsTempFd(tmpfilename, sizeof(tmpfilename))) < 0) { _cupsLangPrintError(_("ERROR: Unable to create temporary file")); @@ -429,6 +439,7 @@ main(int argc, /* I - Number of command-line args */ tbytes = 0; while ((bytes = fread(buffer, 1, sizeof(buffer), stdin)) > 0) + { if (write(fd, buffer, bytes) < bytes) { _cupsLangPrintError(_("ERROR: Unable to write to temporary file")); @@ -439,6 +450,15 @@ main(int argc, /* I - Number of command-line args */ else tbytes += bytes; + if (snmp_fd >= 0) + backendCheckSideChannel(snmp_fd, &(addrlist->addr)); + } + + if (snmp_fd >= 0) + _cupsSNMPClose(snmp_fd); + + httpAddrFreeList(addrlist); + close(fd); /* |