From: Michael R Sweet Date: Wed, 15 Dec 2021 23:47:37 +0000 (-0500) Subject: Normalize debug logging. X-Git-Tag: v2.4.1~20 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c245f7eaf6c8693d25a34a89580a1a6f675b62d9;p=thirdparty%2Fcups.git Normalize debug logging. --- diff --git a/cups/http.c b/cups/http.c index 66dd3b071e..bd41e6f8ed 100644 --- a/cups/http.c +++ b/cups/http.c @@ -4042,9 +4042,9 @@ http_debug_hex(const char *prefix, /* I - Prefix for line */ if (_cups_debug_fd < 0 || _cups_debug_level < 6) return; - DEBUG_printf(("6%s: %d bytes:", prefix, bytes)); + DEBUG_printf(("9%s: %d bytes:", prefix, bytes)); - snprintf(line, sizeof(line), "6%s: ", prefix); + snprintf(line, sizeof(line), "9%s: ", prefix); start = line + strlen(line); for (i = 0; i < bytes; i += 16) @@ -4094,7 +4094,7 @@ http_read(http_t *http, /* I - HTTP connection */ ssize_t bytes; /* Bytes read */ - DEBUG_printf(("http_read(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length)); + DEBUG_printf(("7http_read(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length)); if (!http->blocking || http->timeout_value > 0.0) { @@ -4103,12 +4103,12 @@ http_read(http_t *http, /* I - HTTP connection */ if (http->timeout_cb && (*http->timeout_cb)(http, http->timeout_data)) continue; - DEBUG_puts("2http_read: Timeout."); + DEBUG_puts("8http_read: Timeout."); return (0); } } - DEBUG_printf(("2http_read: Reading %d bytes into buffer.", (int)length)); + DEBUG_printf(("8http_read: Reading %d bytes into buffer.", (int)length)); do { @@ -4137,7 +4137,7 @@ http_read(http_t *http, /* I - HTTP connection */ } } #else - DEBUG_printf(("2http_read: %s", strerror(errno))); + DEBUG_printf(("8http_read: %s", strerror(errno))); if (errno == EWOULDBLOCK || errno == EAGAIN) { @@ -4162,8 +4162,7 @@ http_read(http_t *http, /* I - HTTP connection */ } while (bytes < 0); - DEBUG_printf(("2http_read: Read " CUPS_LLFMT " bytes into buffer.", - CUPS_LLCAST bytes)); + DEBUG_printf(("8http_read: Read " CUPS_LLFMT " bytes into buffer.", CUPS_LLCAST bytes)); #ifdef DEBUG if (bytes > 0) http_debug_hex("http_read", buffer, (int)bytes); @@ -4193,7 +4192,7 @@ http_read_buffered(http_t *http, /* I - HTTP connection */ ssize_t bytes; /* Bytes read */ - DEBUG_printf(("http_read_buffered(http=%p, buffer=%p, length=" CUPS_LLFMT ") used=%d", (void *)http, (void *)buffer, CUPS_LLCAST length, http->used)); + DEBUG_printf(("7http_read_buffered(http=%p, buffer=%p, length=" CUPS_LLFMT ") used=%d", (void *)http, (void *)buffer, CUPS_LLCAST length, http->used)); if (http->used > 0) { @@ -4202,7 +4201,7 @@ http_read_buffered(http_t *http, /* I - HTTP connection */ else bytes = (ssize_t)length; - DEBUG_printf(("2http_read: Grabbing %d bytes from input buffer.", + DEBUG_printf(("8http_read: Grabbing %d bytes from input buffer.", (int)bytes)); memcpy(buffer, http->buffer, (size_t)bytes); @@ -4230,7 +4229,7 @@ http_read_chunk(http_t *http, /* I - HTTP connection */ char *buffer, /* I - Buffer */ size_t length) /* I - Maximum bytes to read */ { - DEBUG_printf(("http_read_chunk(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length)); + DEBUG_printf(("7http_read_chunk(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length)); if (http->data_remaining <= 0) { @@ -4238,16 +4237,16 @@ http_read_chunk(http_t *http, /* I - HTTP connection */ if (!httpGets(len, sizeof(len), http)) { - DEBUG_puts("1http_read_chunk: Could not get chunk length."); + DEBUG_puts("8http_read_chunk: Could not get chunk length."); return (0); } if (!len[0]) { - DEBUG_puts("1http_read_chunk: Blank chunk length, trying again..."); + DEBUG_puts("8http_read_chunk: Blank chunk length, trying again..."); if (!httpGets(len, sizeof(len), http)) { - DEBUG_puts("1http_read_chunk: Could not get chunk length."); + DEBUG_puts("8http_read_chunk: Could not get chunk length."); return (0); } } @@ -4256,12 +4255,12 @@ http_read_chunk(http_t *http, /* I - HTTP connection */ if (http->data_remaining < 0) { - DEBUG_printf(("1http_read_chunk: Negative chunk length \"%s\" (" + DEBUG_printf(("8http_read_chunk: Negative chunk length \"%s\" (" CUPS_LLFMT ")", len, CUPS_LLCAST http->data_remaining)); return (0); } - DEBUG_printf(("2http_read_chunk: Got chunk length \"%s\" (" CUPS_LLFMT ")", + DEBUG_printf(("8http_read_chunk: Got chunk length \"%s\" (" CUPS_LLFMT ")", len, CUPS_LLCAST http->data_remaining)); if (http->data_remaining == 0) @@ -4274,7 +4273,7 @@ http_read_chunk(http_t *http, /* I - HTTP connection */ } } - DEBUG_printf(("2http_read_chunk: data_remaining=" CUPS_LLFMT, + DEBUG_printf(("8http_read_chunk: data_remaining=" CUPS_LLFMT, CUPS_LLCAST http->data_remaining)); if (http->data_remaining <= 0) @@ -4487,7 +4486,7 @@ http_set_length(http_t *http) /* I - Connection */ off_t remaining; /* Remainder */ - DEBUG_printf(("http_set_length(http=%p) mode=%d state=%s", (void *)http, http->mode, httpStateString(http->state))); + DEBUG_printf(("4http_set_length(http=%p) mode=%d state=%s", (void *)http, http->mode, httpStateString(http->state))); if ((remaining = httpGetLength2(http)) >= 0) { @@ -4497,25 +4496,22 @@ http_set_length(http_t *http) /* I - Connection */ http->state != HTTP_STATE_POST && http->state != HTTP_STATE_POST_SEND) { - DEBUG_puts("1http_set_length: Not setting data_encoding/remaining."); + DEBUG_puts("5http_set_length: Not setting data_encoding/remaining."); return (remaining); } if (!_cups_strcasecmp(httpGetField(http, HTTP_FIELD_TRANSFER_ENCODING), "chunked")) { - DEBUG_puts("1http_set_length: Setting data_encoding to " - "HTTP_ENCODING_CHUNKED."); + DEBUG_puts("5http_set_length: Setting data_encoding to HTTP_ENCODING_CHUNKED."); http->data_encoding = HTTP_ENCODING_CHUNKED; } else { - DEBUG_puts("1http_set_length: Setting data_encoding to " - "HTTP_ENCODING_LENGTH."); + DEBUG_puts("5http_set_length: Setting data_encoding to HTTP_ENCODING_LENGTH."); http->data_encoding = HTTP_ENCODING_LENGTH; } - DEBUG_printf(("1http_set_length: Setting data_remaining to " CUPS_LLFMT ".", - CUPS_LLCAST remaining)); + DEBUG_printf(("5http_set_length: Setting data_remaining to " CUPS_LLFMT ".", CUPS_LLCAST remaining)); http->data_remaining = remaining; if (remaining <= INT_MAX) @@ -4585,7 +4581,7 @@ http_tls_upgrade(http_t *http) /* I - HTTP connection */ http_t myhttp; /* Local copy of HTTP data */ - DEBUG_printf(("7http_tls_upgrade(%p)", (void *)http)); + DEBUG_printf(("4http_tls_upgrade(%p)", (void *)http)); /* * Flush the connection to make sure any previous "Upgrade" message @@ -4651,7 +4647,7 @@ http_tls_upgrade(http_t *http) /* I - HTTP connection */ * Server does not support HTTP upgrade... */ - DEBUG_puts("8http_tls_upgrade: Server does not support HTTP upgrade!"); + DEBUG_puts("5http_tls_upgrade: Server does not support HTTP upgrade!"); _cupsSetError(IPP_STATUS_ERROR_CUPS_PKI, _("Encryption is not supported."), 1); httpAddrClose(NULL, http->fd); @@ -4679,13 +4675,13 @@ http_write(http_t *http, /* I - HTTP connection */ bytes; /* Bytes sent */ - DEBUG_printf(("2http_write(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length)); + DEBUG_printf(("7http_write(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length)); http->error = 0; tbytes = 0; while (length > 0) { - DEBUG_printf(("3http_write: About to write %d bytes.", (int)length)); + DEBUG_printf(("8http_write: About to write %d bytes.", (int)length)); if (http->timeout_value > 0.0) { @@ -4751,8 +4747,7 @@ http_write(http_t *http, /* I - HTTP connection */ #endif /* HAVE_TLS */ bytes = send(http->fd, buffer, length, 0); - DEBUG_printf(("3http_write: Write of " CUPS_LLFMT " bytes returned " - CUPS_LLFMT ".", CUPS_LLCAST length, CUPS_LLCAST bytes)); + DEBUG_printf(("8http_write: Write of " CUPS_LLFMT " bytes returned " CUPS_LLFMT ".", CUPS_LLCAST length, CUPS_LLCAST bytes)); if (bytes < 0) { @@ -4792,8 +4787,7 @@ http_write(http_t *http, /* I - HTTP connection */ } #endif /* _WIN32 */ - DEBUG_printf(("3http_write: error writing data (%s).", - strerror(http->error))); + DEBUG_printf(("8http_write: error writing data (%s).", strerror(http->error))); return (-1); } @@ -4807,7 +4801,7 @@ http_write(http_t *http, /* I - HTTP connection */ http_debug_hex("http_write", buffer - tbytes, (int)tbytes); #endif /* DEBUG */ - DEBUG_printf(("3http_write: Returning " CUPS_LLFMT ".", CUPS_LLCAST tbytes)); + DEBUG_printf(("8http_write: Returning " CUPS_LLFMT ".", CUPS_LLCAST tbytes)); return (tbytes); } diff --git a/cups/tls-darwin.c b/cups/tls-darwin.c index 0741a320e7..9834c3c26a 100644 --- a/cups/tls-darwin.c +++ b/cups/tls-darwin.c @@ -1158,8 +1158,7 @@ _httpTLSRead(http_t *http, /* I - HTTP connection */ error = SSLRead(http->tls, buf, (size_t)len, &processed); - DEBUG_printf(("6_httpTLSRead: error=%d, processed=%d", (int)error, - (int)processed)); + DEBUG_printf(("5_httpTLSRead: error=%d, processed=%d", (int)error, (int)processed)); switch (error) { case 0 : @@ -1474,14 +1473,12 @@ _httpTLSStart(http_t *http) /* I - HTTP connection */ { error = SSLSetSessionOption(http->tls, kSSLSessionOptionBreakOnCertRequested, true); - DEBUG_printf(("4_httpTLSStart: kSSLSessionOptionBreakOnCertRequested, " - "error=%d", (int)error)); + DEBUG_printf(("4_httpTLSStart: kSSLSessionOptionBreakOnCertRequested, error=%d", (int)error)); } else { error = http_cdsa_set_credentials(http); - DEBUG_printf(("4_httpTLSStart: http_cdsa_set_credentials, error=%d", - (int)error)); + DEBUG_printf(("4_httpTLSStart: http_cdsa_set_credentials, error=%d", (int)error)); } } else if (!error) @@ -1650,8 +1647,7 @@ _httpTLSStart(http_t *http) /* I - HTTP connection */ httpFreeCredentials(credentials); } - DEBUG_printf(("4_httpTLSStart: Server certificate callback " - "returned %d.", (int)error)); + DEBUG_printf(("4_httpTLSStart: Server certificate callback returned %d.", (int)error)); } break; @@ -1693,8 +1689,7 @@ _httpTLSStart(http_t *http) /* I - HTTP connection */ error = (cg->client_cert_cb)(http, http->tls, names, cg->client_cert_data); - DEBUG_printf(("4_httpTLSStart: Client certificate callback " - "returned %d.", (int)error)); + DEBUG_printf(("4_httpTLSStart: Client certificate callback returned %d.", (int)error)); } httpFreeCredentials(names); @@ -1702,38 +1697,31 @@ _httpTLSStart(http_t *http) /* I - HTTP connection */ break; case errSSLUnknownRootCert : - message = _("Unable to establish a secure connection to host " - "(untrusted certificate)."); + message = _("Unable to establish a secure connection to host (untrusted certificate)."); break; case errSSLNoRootCert : - message = _("Unable to establish a secure connection to host " - "(self-signed certificate)."); + message = _("Unable to establish a secure connection to host (self-signed certificate)."); break; case errSSLCertExpired : - message = _("Unable to establish a secure connection to host " - "(expired certificate)."); + message = _("Unable to establish a secure connection to host (expired certificate)."); break; case errSSLCertNotYetValid : - message = _("Unable to establish a secure connection to host " - "(certificate not yet valid)."); + message = _("Unable to establish a secure connection to host (certificate not yet valid)."); break; case errSSLHostNameMismatch : - message = _("Unable to establish a secure connection to host " - "(host name mismatch)."); + message = _("Unable to establish a secure connection to host (host name mismatch)."); break; case errSSLXCertChainInvalid : - message = _("Unable to establish a secure connection to host " - "(certificate chain invalid)."); + message = _("Unable to establish a secure connection to host (certificate chain invalid)."); break; case errSSLConnectionRefused : - message = _("Unable to establish a secure connection to host " - "(peer dropped connection before responding)."); + message = _("Unable to establish a secure connection to host (peer dropped connection before responding)."); break; default : @@ -1813,7 +1801,7 @@ _httpTLSWrite(http_t *http, /* I - HTTP connection */ size_t processed; /* Number of bytes processed */ - DEBUG_printf(("2_httpTLSWrite(http=%p, buf=%p, len=%d)", (void *)http, (void *)buf, len)); + DEBUG_printf(("4_httpTLSWrite(http=%p, buf=%p, len=%d)", (void *)http, (void *)buf, len)); error = SSLWrite(http->tls, buf, (size_t)len, &processed); @@ -1849,7 +1837,7 @@ _httpTLSWrite(http_t *http, /* I - HTTP connection */ break; } - DEBUG_printf(("3_httpTLSWrite: Returning %d.", (int)result)); + DEBUG_printf(("5_httpTLSWrite: Returning %d.", (int)result)); return ((int)result); } diff --git a/cups/tls-gnutls.c b/cups/tls-gnutls.c index c1dd0a6b07..93e27e1881 100644 --- a/cups/tls-gnutls.c +++ b/cups/tls-gnutls.c @@ -1120,7 +1120,7 @@ http_gnutls_read( ssize_t bytes; /* Bytes read */ - DEBUG_printf(("6http_gnutls_read(ptr=%p, data=%p, length=%d)", ptr, data, (int)length)); + DEBUG_printf(("5http_gnutls_read(ptr=%p, data=%p, length=%d)", ptr, data, (int)length)); http = (http_t *)ptr; @@ -1141,7 +1141,7 @@ http_gnutls_read( } bytes = recv(http->fd, data, length, 0); - DEBUG_printf(("6http_gnutls_read: bytes=%d", (int)bytes)); + DEBUG_printf(("5http_gnutls_read: bytes=%d", (int)bytes)); return (bytes); } @@ -1159,10 +1159,10 @@ http_gnutls_write( ssize_t bytes; /* Bytes written */ - DEBUG_printf(("6http_gnutls_write(ptr=%p, data=%p, length=%d)", ptr, data, + DEBUG_printf(("5http_gnutls_write(ptr=%p, data=%p, length=%d)", ptr, data, (int)length)); bytes = send(((http_t *)ptr)->fd, data, length, 0); - DEBUG_printf(("http_gnutls_write: bytes=%d", (int)bytes)); + DEBUG_printf(("5http_gnutls_write: bytes=%d", (int)bytes)); return (bytes); } @@ -1695,7 +1695,7 @@ _httpTLSWrite(http_t *http, /* I - Connection to server */ ssize_t result; /* Return value */ - DEBUG_printf(("2http_write_ssl(http=%p, buf=%p, len=%d)", http, buf, len)); + DEBUG_printf(("5_httpTLSWrite(http=%p, buf=%p, len=%d)", http, buf, len)); result = gnutls_record_send(http->tls, buf, (size_t)len); @@ -1723,7 +1723,7 @@ _httpTLSWrite(http_t *http, /* I - Connection to server */ result = -1; } - DEBUG_printf(("3http_write_ssl: Returning %d.", (int)result)); + DEBUG_printf(("5_httpTLSWrite: Returning %d.", (int)result)); return ((int)result); } diff --git a/cups/tls-sspi.c b/cups/tls-sspi.c index 77af3f3aea..7493400f89 100644 --- a/cups/tls-sspi.c +++ b/cups/tls-sspi.c @@ -758,13 +758,13 @@ _httpTLSRead(http_t *http, /* I - HTTP connection */ if (sspi->decryptBufferLength >= 262144) { WSASetLastError(E_OUTOFMEMORY); - DEBUG_puts("_httpTLSRead: Decryption buffer too large (>256k)"); + DEBUG_puts("5_httpTLSRead: Decryption buffer too large (>256k)"); return (-1); } if ((temp = realloc(sspi->decryptBuffer, sspi->decryptBufferLength + 4096)) == NULL) { - DEBUG_printf(("_httpTLSRead: Unable to allocate %d byte decryption buffer.", sspi->decryptBufferLength + 4096)); + DEBUG_printf(("5_httpTLSRead: Unable to allocate %d byte decryption buffer.", sspi->decryptBufferLength + 4096)); WSASetLastError(E_OUTOFMEMORY); return (-1); } @@ -772,7 +772,7 @@ _httpTLSRead(http_t *http, /* I - HTTP connection */ sspi->decryptBufferLength += 4096; sspi->decryptBuffer = temp; - DEBUG_printf(("_httpTLSRead: Resized decryption buffer to %d bytes.", sspi->decryptBufferLength)); + DEBUG_printf(("5_httpTLSRead: Resized decryption buffer to %d bytes.", sspi->decryptBufferLength)); } buffers[0].pvBuffer = sspi->decryptBuffer; @@ -863,7 +863,7 @@ _httpTLSRead(http_t *http, /* I - HTTP connection */ if ((temp = realloc(sspi->readBuffer, sspi->readBufferUsed + bytesToSave)) == NULL) { - DEBUG_printf(("_httpTLSRead: Unable to allocate %d bytes.", sspi->readBufferUsed + bytesToSave)); + DEBUG_printf(("5_httpTLSRead: Unable to allocate %d bytes.", sspi->readBufferUsed + bytesToSave)); WSASetLastError(E_OUTOFMEMORY); return (-1); } @@ -881,7 +881,7 @@ _httpTLSRead(http_t *http, /* I - HTTP connection */ } else { - DEBUG_puts("_httpTLSRead: Unable to find data buffer."); + DEBUG_puts("5_httpTLSRead: Unable to find data buffer."); WSASetLastError(WSASYSCALLFAILURE); return (-1); } @@ -1092,7 +1092,7 @@ _httpTLSStop(http_t *http) /* I - HTTP connection */ if ((cbData == SOCKET_ERROR) || (cbData == 0)) { status = WSAGetLastError(); - DEBUG_printf(("_httpTLSStop: sending close notify failed: %d", status)); + DEBUG_printf(("4_httpTLSStop: sending close notify failed: %d", status)); } else { @@ -1102,12 +1102,12 @@ _httpTLSStop(http_t *http) /* I - HTTP connection */ } else { - DEBUG_printf(("_httpTLSStop: AcceptSecurityContext failed: %s", http_sspi_strerror(sspi->error, sizeof(sspi->error), status))); + DEBUG_printf(("4_httpTLSStop: AcceptSecurityContext failed: %s", http_sspi_strerror(sspi->error, sizeof(sspi->error), status))); } } else { - DEBUG_printf(("_httpTLSStop: ApplyControlToken failed: %s", http_sspi_strerror(sspi->error, sizeof(sspi->error), status))); + DEBUG_printf(("4_httpTLSStop: ApplyControlToken failed: %s", http_sspi_strerror(sspi->error, sizeof(sspi->error), status))); } } @@ -1143,7 +1143,7 @@ _httpTLSWrite(http_t *http, /* I - HTTP connection */ if ((temp = (BYTE *)realloc(sspi->writeBuffer, bufferLen)) == NULL) { - DEBUG_printf(("_httpTLSWrite: Unable to allocate buffer of %d bytes.", bufferLen)); + DEBUG_printf(("5_httpTLSWrite: Unable to allocate buffer of %d bytes.", bufferLen)); WSASetLastError(E_OUTOFMEMORY); return (-1); } @@ -1194,7 +1194,7 @@ _httpTLSWrite(http_t *http, /* I - HTTP connection */ if (FAILED(scRet)) { - DEBUG_printf(("_httpTLSWrite: EncryptMessage failed: %s", http_sspi_strerror(sspi->error, sizeof(sspi->error), scRet))); + DEBUG_printf(("5_httpTLSWrite: EncryptMessage failed: %s", http_sspi_strerror(sspi->error, sizeof(sspi->error), scRet))); WSASetLastError(WSASYSCALLFAILURE); return (-1); } @@ -1209,7 +1209,7 @@ _httpTLSWrite(http_t *http, /* I - HTTP connection */ if (num <= 0) { - DEBUG_printf(("_httpTLSWrite: send failed: %ld", WSAGetLastError())); + DEBUG_printf(("5_httpTLSWrite: send failed: %ld", WSAGetLastError())); return (num); } @@ -2402,7 +2402,7 @@ http_sspi_verify( { status = GetLastError(); - DEBUG_printf(("CertGetCertificateChain returned: %s", http_sspi_strerror(error, sizeof(error), status))); + DEBUG_printf(("5http_sspi_verify: CertGetCertificateChain returned: %s", http_sspi_strerror(error, sizeof(error), status))); LocalFree(commonNameUnicode); return (status); @@ -2429,7 +2429,7 @@ http_sspi_verify( { status = GetLastError(); - DEBUG_printf(("CertVerifyCertificateChainPolicy returned %s", http_sspi_strerror(error, sizeof(error), status))); + DEBUG_printf(("5http_sspi_verify: CertVerifyCertificateChainPolicy returned %s", http_sspi_strerror(error, sizeof(error), status))); } else if (policyStatus.dwError) status = policyStatus.dwError;