Skip to content

Commit 24b37fe

Browse files
committed
Sync up documentation and other changes from libcups.
1 parent 5fb0cd4 commit 24b37fe

4 files changed

Lines changed: 1422 additions & 1368 deletions

File tree

cups/http-addr.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,30 @@ httpAddrEqual(const http_addr_t *addr1, // I - First address
8080
}
8181

8282

83+
//
84+
// 'httpAddrIsAny()' - Check for the "any" address.
85+
//
86+
// @since CUPS 2.5@
87+
//
88+
89+
bool // O - `true` if "any" address, `false` otherwise
90+
httpAddrIsAny(const http_addr_t *addr) // I - Address to check
91+
{
92+
if (!addr)
93+
return (false);
94+
95+
#ifdef AF_INET6
96+
if (addr->addr.sa_family == AF_INET6 && IN6_IS_ADDR_UNSPECIFIED(&(addr->ipv6.sin6_addr)))
97+
return (true);
98+
#endif // AF_INET6
99+
100+
if (addr->addr.sa_family == AF_INET && ntohl(addr->ipv4.sin_addr.s_addr) == 0x00000000)
101+
return (true);
102+
103+
return (false);
104+
}
105+
106+
83107
//
84108
// 'httpAddrIsEqual()' - Compare two addresses.
85109
//
@@ -114,30 +138,6 @@ httpAddrIsEqual(
114138
}
115139

116140

117-
//
118-
// 'httpAddrIsAny()' - Check for the "any" address.
119-
//
120-
// @since CUPS 2.5@
121-
//
122-
123-
bool // O - `true` if "any" address, `false` otherwise
124-
httpAddrIsAny(const http_addr_t *addr) // I - Address to check
125-
{
126-
if (!addr)
127-
return (false);
128-
129-
#ifdef AF_INET6
130-
if (addr->addr.sa_family == AF_INET6 && IN6_IS_ADDR_UNSPECIFIED(&(addr->ipv6.sin6_addr)))
131-
return (true);
132-
#endif // AF_INET6
133-
134-
if (addr->addr.sa_family == AF_INET && ntohl(addr->ipv4.sin_addr.s_addr) == 0x00000000)
135-
return (true);
136-
137-
return (false);
138-
}
139-
140-
141141
//
142142
// 'httpAddrLength()' - Return the length of the address in bytes.
143143
//
@@ -228,10 +228,10 @@ httpAddrListen(http_addr_t *addr, // I - Address to bind to
228228
// Remove any existing domain socket file...
229229
if ((status = unlink(addr->un.sun_path)) < 0)
230230
{
231-
DEBUG_printf("1httpAddrListen: Unable to unlink \"%s\": %s", addr->un.sun_path, strerror(errno));
232-
233231
if (errno == ENOENT)
234232
status = 0;
233+
else
234+
DEBUG_printf("1httpAddrListen: Unable to unlink \"%s\": %s", addr->un.sun_path, strerror(errno));
235235
}
236236

237237
if (!status)
@@ -242,9 +242,7 @@ httpAddrListen(http_addr_t *addr, // I - Address to bind to
242242

243243
// Bind the domain socket...
244244
if ((status = bind(fd, (struct sockaddr *)addr, (socklen_t)httpAddrLength(addr))) < 0)
245-
{
246245
DEBUG_printf("1httpAddrListen: Unable to bind domain socket \"%s\": %s", addr->un.sun_path, strerror(errno));
247-
}
248246

249247
// Restore the umask...
250248
umask(mask);
@@ -255,11 +253,13 @@ httpAddrListen(http_addr_t *addr, // I - Address to bind to
255253
{
256254
httpAddrSetPort(addr, port);
257255

258-
status = bind(fd, (struct sockaddr *)addr, (socklen_t)httpAddrLength(addr));
256+
if ((status = bind(fd, (struct sockaddr *)addr, (socklen_t)httpAddrLength(addr))) < 0)
257+
DEBUG_printf("1httpAddrListen: Unable to bind network socket: %s", strerror(errno));
259258
}
260259

261260
if (status)
262261
{
262+
DEBUG_printf("1httpAddrListen: Unable to listen on socket: %s", strerror(errno));
263263
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
264264

265265
close(fd);
@@ -818,7 +818,7 @@ httpGetHostname(http_t *http, // I - HTTP connection or NULL
818818

819819
const char * // O - Resolved hostname or `NULL`
820820
httpResolveHostname(http_t *http, // I - HTTP connection
821-
char *buffer, // I - Hostname buffer
821+
char *buffer, // I - Hostname buffer or `NULL` to use HTTP buffer
822822
size_t bufsize) // I - Size of buffer
823823
{
824824
if (!http)

cups/http-support.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ httpAssembleURI(
204204
}
205205
else
206206
{
207-
goto assemble_overflow;
208-
}
207+
goto assemble_overflow;
208+
}
209209
}
210210
else
211211
{
@@ -406,7 +406,7 @@ httpAssembleUUID(const char *server, // I - Server name
406406
//
407407
// Start with the MD5 sum of the server, port, object name and
408408
// number, and some random data on the end.
409-
snprintf(data, sizeof(data), "%s:%d:%s:%d:%04x:%04x", server, port, name ? name : server, number, (unsigned)CUPS_RAND() & 0xffff, (unsigned)CUPS_RAND() & 0xffff);
409+
snprintf(data, sizeof(data), "%s:%d:%s:%d:%04x:%04x", server, port, name ? name : server, number, (unsigned)cupsGetRand() & 0xffff, (unsigned)cupsGetRand() & 0xffff);
410410

411411
cupsHashData("md5", (unsigned char *)data, strlen(data), md5sum, sizeof(md5sum));
412412

@@ -625,7 +625,7 @@ httpEncode64_2(char *out, // I - String to write to
625625
// 'httpEncode64_3()' - Base64-encode a string.
626626
//
627627
// This function encodes a Base64 string as defined by RFC 4648. The "url"
628-
// parameter controls whether the original Base64 ("url" = `false`) or the
628+
// argument controls whether the original Base64 ("url" = `false`) or the
629629
// Base64url ("url" = `true`) alphabet is used.
630630
//
631631
// @since CUPS 2.5@
@@ -1195,7 +1195,7 @@ _httpSetDigestAuthString(
11951195
DEBUG_puts("3_httpSetDigestAuthString: Follow RFC 2617/7616...");
11961196

11971197
for (i = 0; i < 64; i ++)
1198-
cnonce[i] = "0123456789ABCDEF"[CUPS_RAND() & 15];
1198+
cnonce[i] = "0123456789ABCDEF"[cupsGetRand() & 15];
11991199
cnonce[64] = '\0';
12001200

12011201
if (!_cups_strcasecmp(http->qop, "auth"))
@@ -1429,8 +1429,8 @@ httpStatus(http_status_t status) // I - HTTP status code
14291429
//
14301430
// 'httpStatusString()' - Return a short string describing a HTTP status code.
14311431
//
1432-
// The returned string is localized to the current POSIX locale and is based
1433-
// on the status strings defined in RFC 7231.
1432+
// This function returns a short (localized) string describing a HTTP status
1433+
// code. The strings are taken from the IANA HTTP Status Code registry.
14341434
//
14351435
// @since CUPS 2.5@
14361436
//
@@ -1450,6 +1450,9 @@ httpStatusString(http_status_t status) // I - HTTP status code
14501450
//
14511451
// 'httpURIStatusString()' - Return a string describing a URI status code.
14521452
//
1453+
// This function returns a short (localized) string describing a URI status
1454+
// value.
1455+
//
14531456
// @since CUPS 2.0/OS 10.10@
14541457
//
14551458

@@ -1573,13 +1576,13 @@ _httpEncodeURI(char *dst, // I - Destination buffer
15731576
//
15741577
// This function resolves a DNS-SD URI of the form
15751578
// "scheme://service-instance-name._protocol._tcp.domain/...". The "options"
1576-
// parameter specifies a bitfield of resolution options including:
1579+
// argument specifies a bitfield of resolution options including:
15771580
//
15781581
// - `HTTP_RESOLVE_DEFAULT`: Use default options
15791582
// - `HTTP_RESOLVE_FQDN`: Resolve the fully-qualified domain name instead of an IP address
15801583
// - `HTTP_RESOLVE_FAXOUT`: Resolve the FaxOut service instead of Print (IPP/IPPS)
15811584
//
1582-
// The "cb" parameter specifies a callback that allows resolution to be
1585+
// The "cb" argument specifies a callback that allows resolution to be
15831586
// terminated. The callback is provided the "cb_data" value and returns a
15841587
// `bool` value that is `true` to continue and `false` to stop. If no callback
15851588
// is specified ("cb" is `NULL`), then this function will block up to 90 seconds

0 commit comments

Comments
 (0)