]> git.ipfire.org Git - thirdparty/cups.git/blame - cups/http-support.c
Merge changes from CUPS 1.4svn-r7844.
[thirdparty/cups.git] / cups / http-support.c
CommitLineData
ef416fc2 1/*
5eb9da71 2 * "$Id: http-support.c 7583 2008-05-16 17:47:16Z mike $"
ef416fc2 3 *
4 * HTTP support routines for the Common UNIX Printing System (CUPS) scheduler.
5 *
9f5eb9be 6 * Copyright 2007-2008 by Apple Inc.
b86bc4cf 7 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
ef416fc2 8 *
9 * These coded instructions, statements, and computer programs are the
bc44d920 10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
ef416fc2 14 *
15 * This file is subject to the Apple OS-Developed Software exception.
16 *
17 * Contents:
18 *
19 * httpAssembleURI() - Assemble a uniform resource identifier from its
20 * components.
21 * httpAssembleURIf() - Assemble a uniform resource identifier from its
22 * components with a formatted resource.
23 * httpDecode64() - Base64-decode a string.
24 * httpDecode64_2() - Base64-decode a string.
25 * httpEncode64() - Base64-encode a string.
26 * httpEncode64_2() - Base64-encode a string.
27 * httpGetDateString() - Get a formatted date/time string from a time value.
28 * httpGetDateString2() - Get a formatted date/time string from a time value.
29 * httpGetDateTime() - Get a time value from a formatted date/time string.
30 * httpSeparate() - Separate a Universal Resource Identifier into its
31 * components.
32 * httpSeparate2() - Separate a Universal Resource Identifier into its
33 * components.
34 * httpSeparateURI() - Separate a Universal Resource Identifier into its
35 * components.
36 * httpStatus() - Return a short string describing a HTTP status code.
37 * _cups_hstrerror() - hstrerror() emulation function for Solaris and
38 * others...
839a51c8 39 * _httpEncodeURI() - Percent-encode a HTTP request URI.
5eb9da71 40 * _httpResolveURI() - Resolve a DNS-SD URI.
ef416fc2 41 * http_copy_decode() - Copy and decode a URI.
42 * http_copy_encode() - Copy and encode a URI.
5eb9da71 43 * resolve_callback() - Build a device URI for the given service name.
ef416fc2 44 */
45
46/*
47 * Include necessary headers...
48 */
49
50#include "debug.h"
51#include "globals.h"
52#include <stdlib.h>
5eb9da71
MS
53#ifdef HAVE_DNSSD
54# include <dns_sd.h>
55#endif /* HAVE_DNSSD */
56
57
58/*
59 * Local types...
60 */
61
62typedef struct _http_uribuf_s /* URI buffer */
63{
64 char *buffer; /* Pointer to buffer */
65 size_t bufsize; /* Size of buffer */
66} _http_uribuf_t;
ef416fc2 67
68
69/*
70 * Local globals...
71 */
72
73static const char * const http_days[7] =
74 {
0a682745
MS
75 "Sun",
76 "Mon",
ef416fc2 77 "Tue",
78 "Wed",
79 "Thu",
80 "Fri",
81 "Sat"
82 };
83static const char * const http_months[12] =
84 {
85 "Jan",
86 "Feb",
87 "Mar",
88 "Apr",
89 "May",
90 "Jun",
91 "Jul",
92 "Aug",
93 "Sep",
94 "Oct",
95 "Nov",
96 "Dec"
97 };
98
99
100/*
101 * Local functions...
102 */
103
104static const char *http_copy_decode(char *dst, const char *src,
a4d04587 105 int dstsize, const char *term,
106 int decode);
ef416fc2 107static char *http_copy_encode(char *dst, const char *src,
a4d04587 108 char *dstend, const char *reserved,
109 const char *term, int encode);
5eb9da71
MS
110#ifdef HAVE_DNSSD
111static void resolve_callback(DNSServiceRef sdRef,
112 DNSServiceFlags flags,
113 uint32_t interfaceIndex,
114 DNSServiceErrorType errorCode,
115 const char *fullName,
116 const char *hostTarget,
117 uint16_t port, uint16_t txtLen,
118 const unsigned char *txtRecord,
119 void *context);
120#endif /* HAVE_DNSSD */
ef416fc2 121
122
123/*
124 * 'httpAssembleURI()' - Assemble a uniform resource identifier from its
125 * components.
126 *
ecdc0628 127 * This function escapes reserved characters in the URI depending on the
128 * value of the "encoding" argument. You should use this function in
129 * place of traditional string functions whenever you need to create a
130 * URI string.
ef416fc2 131 *
132 * @since CUPS 1.2@
133 */
134
135http_uri_status_t /* O - URI status */
a4d04587 136httpAssembleURI(
137 http_uri_coding_t encoding, /* I - Encoding flags */
138 char *uri, /* I - URI buffer */
139 int urilen, /* I - Size of URI buffer */
140 const char *scheme, /* I - Scheme name */
141 const char *username, /* I - Username */
142 const char *host, /* I - Hostname or address */
143 int port, /* I - Port number */
144 const char *resource) /* I - Resource */
ef416fc2 145{
146 char *ptr, /* Pointer into URI buffer */
147 *end; /* End of URI buffer */
ef416fc2 148
149
150 /*
151 * Range check input...
152 */
153
154 if (!uri || urilen < 1 || !scheme || port < 0)
155 {
156 if (uri)
157 *uri = '\0';
158
159 return (HTTP_URI_BAD_ARGUMENTS);
160 }
161
162 /*
163 * Assemble the URI starting with the scheme...
164 */
165
166 end = uri + urilen - 1;
a4d04587 167 ptr = http_copy_encode(uri, scheme, end, NULL, NULL, 0);
ef416fc2 168
169 if (!ptr)
170 goto assemble_overflow;
171
f7deaa1a 172 if (!strcmp(scheme, "mailto"))
ef416fc2 173 {
174 /*
175 * mailto: only has :, no //...
176 */
177
178 if (ptr < end)
179 *ptr++ = ':';
180 else
181 goto assemble_overflow;
182 }
183 else
184 {
185 /*
186 * Schemes other than mailto: all have //...
187 */
188
189 if ((ptr + 2) < end)
190 {
191 *ptr++ = ':';
192 *ptr++ = '/';
193 *ptr++ = '/';
194 }
195 else
196 goto assemble_overflow;
197 }
198
199 /*
200 * Next the username and hostname, if any...
201 */
202
203 if (host)
204 {
205 if (username && *username)
206 {
207 /*
208 * Add username@ first...
209 */
210
a4d04587 211 ptr = http_copy_encode(ptr, username, end, "/?@", NULL,
212 encoding & HTTP_URI_CODING_USERNAME);
ef416fc2 213
214 if (!ptr)
215 goto assemble_overflow;
216
217 if (ptr < end)
218 *ptr++ = '@';
219 else
220 goto assemble_overflow;
221 }
222
223 /*
224 * Then add the hostname. Since IPv6 is a particular pain to deal
c9fc04c6 225 * with, we have several special cases to deal with. If we get
ef416fc2 226 * an IPv6 address with brackets around it, assume it is already in
c9fc04c6
MS
227 * URI format. Since DNS-SD service names can sometimes look like
228 * raw IPv6 addresses, we specifically look for "._tcp" in the name,
229 * too...
ef416fc2 230 */
231
c9fc04c6 232 if (host[0] != '[' && strchr(host, ':') && !strstr(host, "._tcp"))
ef416fc2 233 {
234 /*
c9fc04c6 235 * We have a raw IPv6 address...
ef416fc2 236 */
237
238 if (strchr(host, '%'))
239 {
240 /*
241 * We have a link-local address, add "[v1." prefix...
242 */
243
244 if ((ptr + 4) < end)
245 {
246 *ptr++ = '[';
247 *ptr++ = 'v';
248 *ptr++ = '1';
249 *ptr++ = '.';
250 }
251 else
252 goto assemble_overflow;
253 }
254 else
255 {
256 /*
257 * We have a normal address, add "[" prefix...
258 */
259
260 if (ptr < end)
261 *ptr++ = '[';
262 else
263 goto assemble_overflow;
264 }
265
266 /*
267 * Copy the rest of the IPv6 address, and terminate with "]".
268 */
269
270 while (ptr < end && *host)
271 {
272 if (*host == '%')
273 {
274 *ptr++ = '+'; /* Convert zone separator */
275 host ++;
276 }
277 else
278 *ptr++ = *host++;
279 }
280
281 if (*host)
282 goto assemble_overflow;
283
284 if (ptr < end)
285 *ptr++ = ']';
286 else
287 goto assemble_overflow;
288 }
289 else
290 {
291 /*
292 * Otherwise, just copy the host string...
293 */
294
c9fc04c6 295 ptr = http_copy_encode(ptr, host, end, ":/?#[]@", NULL,
a4d04587 296 encoding & HTTP_URI_CODING_HOSTNAME);
ef416fc2 297
298 if (!ptr)
299 goto assemble_overflow;
300 }
301
302 /*
303 * Finish things off with the port number...
304 */
305
306 if (port > 0)
307 {
308 snprintf(ptr, end - ptr + 1, ":%d", port);
309 ptr += strlen(ptr);
310
311 if (ptr >= end)
312 goto assemble_overflow;
313 }
314 }
315
316 /*
317 * Last but not least, add the resource string...
318 */
319
a4d04587 320 if (resource)
ef416fc2 321 {
fa73b229 322 char *query; /* Pointer to query string */
323
324
fa73b229 325 /*
a4d04587 326 * Copy the resource string up to the query string if present...
fa73b229 327 */
328
a4d04587 329 query = strchr(resource, '?');
330 ptr = http_copy_encode(ptr, resource, end, NULL, "?",
331 encoding & HTTP_URI_CODING_RESOURCE);
ef416fc2 332 if (!ptr)
333 goto assemble_overflow;
fa73b229 334
335 if (query)
336 {
337 /*
338 * Copy query string without encoding...
339 */
340
a4d04587 341 ptr = http_copy_encode(ptr, query, end, NULL, NULL,
342 encoding & HTTP_URI_CODING_QUERY);
343 if (!ptr)
344 goto assemble_overflow;
fa73b229 345 }
ef416fc2 346 }
347 else if (ptr < end)
348 *ptr++ = '/';
349 else
350 goto assemble_overflow;
351
352 /*
353 * Nul-terminate the URI buffer and return with no errors...
354 */
355
356 *ptr = '\0';
357
358 return (HTTP_URI_OK);
359
360 /*
361 * Clear the URI string and return an overflow error; I don't usually
362 * like goto's, but in this case it makes sense...
363 */
364
365 assemble_overflow:
366
367 *uri = '\0';
368 return (HTTP_URI_OVERFLOW);
369}
370
371
a4d04587 372/*
373 * 'httpAssembleURIf()' - Assemble a uniform resource identifier from its
374 * components with a formatted resource.
375 *
376 * This function creates a formatted version of the resource string
ecdc0628 377 * argument "resourcef" and escapes reserved characters in the URI
378 * depending on the value of the "encoding" argument. You should use
379 * this function in place of traditional string functions whenever
380 * you need to create a URI string.
a4d04587 381 *
382 * @since CUPS 1.2@
383 */
384
385http_uri_status_t /* O - URI status */
386httpAssembleURIf(
387 http_uri_coding_t encoding, /* I - Encoding flags */
388 char *uri, /* I - URI buffer */
389 int urilen, /* I - Size of URI buffer */
390 const char *scheme, /* I - Scheme name */
391 const char *username, /* I - Username */
392 const char *host, /* I - Hostname or address */
393 int port, /* I - Port number */
394 const char *resourcef, /* I - Printf-style resource */
395 ...) /* I - Additional arguments as needed */
396{
397 va_list ap; /* Pointer to additional arguments */
398 char resource[1024]; /* Formatted resource string */
399 int bytes; /* Bytes in formatted string */
400
401
402 /*
403 * Range check input...
404 */
405
406 if (!uri || urilen < 1 || !scheme || port < 0 || !resourcef)
407 {
408 if (uri)
409 *uri = '\0';
410
411 return (HTTP_URI_BAD_ARGUMENTS);
412 }
413
414 /*
415 * Format the resource string and assemble the URI...
416 */
417
418 va_start(ap, resourcef);
419 bytes = vsnprintf(resource, sizeof(resource), resourcef, ap);
420 va_end(ap);
421
422 if (bytes >= sizeof(resource))
423 {
424 *uri = '\0';
425 return (HTTP_URI_OVERFLOW);
426 }
427 else
428 return (httpAssembleURI(encoding, uri, urilen, scheme, username, host,
429 port, resource));
430}
431
432
ef416fc2 433/*
434 * 'httpDecode64()' - Base64-decode a string.
ecdc0628 435 *
436 * This function is deprecated. Use the httpDecode64_2() function instead
437 * which provides buffer length arguments.
438 *
439 * @deprecated@
ef416fc2 440 */
441
442char * /* O - Decoded string */
443httpDecode64(char *out, /* I - String to write to */
444 const char *in) /* I - String to read from */
445{
446 int outlen; /* Output buffer length */
447
448
449 /*
450 * Use the old maximum buffer size for binary compatibility...
451 */
452
453 outlen = 512;
454
455 return (httpDecode64_2(out, &outlen, in));
456}
457
458
459/*
460 * 'httpDecode64_2()' - Base64-decode a string.
461 *
462 * @since CUPS 1.1.21@
463 */
464
465char * /* O - Decoded string */
466httpDecode64_2(char *out, /* I - String to write to */
467 int *outlen, /* IO - Size of output string */
468 const char *in) /* I - String to read from */
469{
470 int pos, /* Bit position */
471 base64; /* Value of this character */
472 char *outptr, /* Output pointer */
473 *outend; /* End of output buffer */
474
475
476 /*
477 * Range check input...
478 */
479
fa73b229 480 if (!out || !outlen || *outlen < 1 || !in)
ef416fc2 481 return (NULL);
482
fa73b229 483 if (!*in)
484 {
485 *out = '\0';
486 *outlen = 0;
487
488 return (out);
489 }
490
ef416fc2 491 /*
492 * Convert from base-64 to bytes...
493 */
494
495 for (outptr = out, outend = out + *outlen - 1, pos = 0; *in != '\0'; in ++)
496 {
497 /*
498 * Decode this character into a number from 0 to 63...
499 */
500
501 if (*in >= 'A' && *in <= 'Z')
502 base64 = *in - 'A';
503 else if (*in >= 'a' && *in <= 'z')
504 base64 = *in - 'a' + 26;
505 else if (*in >= '0' && *in <= '9')
506 base64 = *in - '0' + 52;
507 else if (*in == '+')
508 base64 = 62;
509 else if (*in == '/')
510 base64 = 63;
511 else if (*in == '=')
512 break;
513 else
514 continue;
515
516 /*
517 * Store the result in the appropriate chars...
518 */
519
520 switch (pos)
521 {
522 case 0 :
523 if (outptr < outend)
524 *outptr = base64 << 2;
525 pos ++;
526 break;
527 case 1 :
528 if (outptr < outend)
529 *outptr++ |= (base64 >> 4) & 3;
530 if (outptr < outend)
531 *outptr = (base64 << 4) & 255;
532 pos ++;
533 break;
534 case 2 :
535 if (outptr < outend)
536 *outptr++ |= (base64 >> 2) & 15;
537 if (outptr < outend)
538 *outptr = (base64 << 6) & 255;
539 pos ++;
540 break;
541 case 3 :
542 if (outptr < outend)
543 *outptr++ |= base64;
544 pos = 0;
545 break;
546 }
547 }
548
549 *outptr = '\0';
550
551 /*
552 * Return the decoded string and size...
553 */
554
555 *outlen = (int)(outptr - out);
556
557 return (out);
558}
559
560
561/*
562 * 'httpEncode64()' - Base64-encode a string.
ecdc0628 563 *
564 * This function is deprecated. Use the httpEncode64_2() function instead
565 * which provides buffer length arguments.
566 *
567 * @deprecated@
ef416fc2 568 */
569
570char * /* O - Encoded string */
571httpEncode64(char *out, /* I - String to write to */
572 const char *in) /* I - String to read from */
573{
b86bc4cf 574 return (httpEncode64_2(out, 512, in, (int)strlen(in)));
ef416fc2 575}
576
577
578/*
579 * 'httpEncode64_2()' - Base64-encode a string.
580 *
581 * @since CUPS 1.1.21@
582 */
583
584char * /* O - Encoded string */
585httpEncode64_2(char *out, /* I - String to write to */
586 int outlen, /* I - Size of output string */
587 const char *in, /* I - String to read from */
588 int inlen) /* I - Size of input string */
589{
590 char *outptr, /* Output pointer */
591 *outend; /* End of output buffer */
592 static const char base64[] = /* Base64 characters... */
593 {
594 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
595 "abcdefghijklmnopqrstuvwxyz"
596 "0123456789"
597 "+/"
598 };
599
600
601 /*
602 * Range check input...
603 */
604
605 if (!out || outlen < 1 || !in)
606 return (NULL);
607
608 /*
609 * Convert bytes to base-64...
610 */
611
612 for (outptr = out, outend = out + outlen - 1; inlen > 0; in ++, inlen --)
613 {
614 /*
615 * Encode the up to 3 characters as 4 Base64 numbers...
616 */
617
618 if (outptr < outend)
619 *outptr ++ = base64[(in[0] & 255) >> 2];
26d47ec6 620
ef416fc2 621 if (outptr < outend)
26d47ec6 622 {
623 if (inlen > 1)
624 *outptr ++ = base64[(((in[0] & 255) << 4) | ((in[1] & 255) >> 4)) & 63];
625 else
626 *outptr ++ = base64[((in[0] & 255) << 4) & 63];
627 }
ef416fc2 628
629 in ++;
630 inlen --;
631 if (inlen <= 0)
632 {
633 if (outptr < outend)
634 *outptr ++ = '=';
635 if (outptr < outend)
636 *outptr ++ = '=';
637 break;
638 }
639
640 if (outptr < outend)
26d47ec6 641 {
642 if (inlen > 1)
643 *outptr ++ = base64[(((in[0] & 255) << 2) | ((in[1] & 255) >> 6)) & 63];
644 else
645 *outptr ++ = base64[((in[0] & 255) << 2) & 63];
646 }
ef416fc2 647
648 in ++;
649 inlen --;
650 if (inlen <= 0)
651 {
652 if (outptr < outend)
653 *outptr ++ = '=';
654 break;
655 }
656
657 if (outptr < outend)
658 *outptr ++ = base64[in[0] & 63];
659 }
660
661 *outptr = '\0';
662
663 /*
664 * Return the encoded string...
665 */
666
667 return (out);
668}
669
670
671/*
672 * 'httpGetDateString()' - Get a formatted date/time string from a time value.
673 *
674 * @deprecated@
675 */
676
677const char * /* O - Date/time string */
678httpGetDateString(time_t t) /* I - UNIX time */
679{
680 _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
681
682
683 return (httpGetDateString2(t, cg->http_date, sizeof(cg->http_date)));
684}
685
686
687/*
688 * 'httpGetDateString2()' - Get a formatted date/time string from a time value.
689 *
690 * @since CUPS 1.2@
691 */
692
693const char * /* O - Date/time string */
694httpGetDateString2(time_t t, /* I - UNIX time */
695 char *s, /* I - String buffer */
696 int slen) /* I - Size of string buffer */
697{
698 struct tm *tdate; /* UNIX date/time data */
699
700
701 tdate = gmtime(&t);
702 snprintf(s, slen, "%s, %02d %s %d %02d:%02d:%02d GMT",
703 http_days[tdate->tm_wday], tdate->tm_mday,
704 http_months[tdate->tm_mon], tdate->tm_year + 1900,
705 tdate->tm_hour, tdate->tm_min, tdate->tm_sec);
706
707 return (s);
708}
709
710
711/*
712 * 'httpGetDateTime()' - Get a time value from a formatted date/time string.
713 */
714
715time_t /* O - UNIX time */
716httpGetDateTime(const char *s) /* I - Date/time string */
717{
718 int i; /* Looping var */
719 char mon[16]; /* Abbreviated month name */
720 int day, year; /* Day of month and year */
721 int hour, min, sec; /* Time */
722 int days; /* Number of days since 1970 */
723 static const int normal_days[] = /* Days to a month, normal years */
724 { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
725 static const int leap_days[] = /* Days to a month, leap years */
726 { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 };
727
728
729 DEBUG_printf(("httpGetDateTime(s=\"%s\")\n", s));
730
731 /*
732 * Extract the date and time from the formatted string...
733 */
734
735 if (sscanf(s, "%*s%d%15s%d%d:%d:%d", &day, mon, &year, &hour, &min, &sec) < 6)
736 return (0);
737
738 DEBUG_printf((" day=%d, mon=\"%s\", year=%d, hour=%d, min=%d, sec=%d\n",
739 day, mon, year, hour, min, sec));
740
741 /*
742 * Convert the month name to a number from 0 to 11.
743 */
744
745 for (i = 0; i < 12; i ++)
746 if (!strcasecmp(mon, http_months[i]))
747 break;
748
749 if (i >= 12)
750 return (0);
751
752 DEBUG_printf((" i=%d\n", i));
753
754 /*
755 * Now convert the date and time to a UNIX time value in seconds since
756 * 1970. We can't use mktime() since the timezone may not be UTC but
757 * the date/time string *is* UTC.
758 */
759
760 if ((year & 3) == 0 && ((year % 100) != 0 || (year % 400) == 0))
761 days = leap_days[i] + day - 1;
762 else
763 days = normal_days[i] + day - 1;
764
765 DEBUG_printf((" days=%d\n", days));
766
767 days += (year - 1970) * 365 + /* 365 days per year (normally) */
768 ((year - 1) / 4 - 492) - /* + leap days */
769 ((year - 1) / 100 - 19) + /* - 100 year days */
770 ((year - 1) / 400 - 4); /* + 400 year days */
771
772 DEBUG_printf((" days=%d\n", days));
773
774 return (days * 86400 + hour * 3600 + min * 60 + sec);
775}
776
777
778/*
779 * 'httpSeparate()' - Separate a Universal Resource Identifier into its
780 * components.
ecdc0628 781 *
782 * This function is deprecated; use the httpSeparateURI() function instead.
783 *
784 * @deprecated@
ef416fc2 785 */
786
787void
788httpSeparate(const char *uri, /* I - Universal Resource Identifier */
789 char *scheme, /* O - Scheme [32] (http, https, etc.) */
790 char *username, /* O - Username [1024] */
791 char *host, /* O - Hostname [1024] */
792 int *port, /* O - Port number to use */
793 char *resource) /* O - Resource/filename [1024] */
794{
a4d04587 795 httpSeparateURI(HTTP_URI_CODING_ALL, uri, scheme, 32, username,
796 HTTP_MAX_URI, host, HTTP_MAX_URI, port, resource,
797 HTTP_MAX_URI);
ef416fc2 798}
799
800
801/*
802 * 'httpSeparate2()' - Separate a Universal Resource Identifier into its
803 * components.
804 *
ecdc0628 805 * This function is deprecated; use the httpSeparateURI() function instead.
806 *
ef416fc2 807 * @since CUPS 1.1.21@
ecdc0628 808 * @deprecated@
ef416fc2 809 */
810
811void
812httpSeparate2(const char *uri, /* I - Universal Resource Identifier */
813 char *scheme, /* O - Scheme (http, https, etc.) */
814 int schemelen, /* I - Size of scheme buffer */
815 char *username, /* O - Username */
816 int usernamelen, /* I - Size of username buffer */
817 char *host, /* O - Hostname */
818 int hostlen, /* I - Size of hostname buffer */
819 int *port, /* O - Port number to use */
820 char *resource, /* O - Resource/filename */
821 int resourcelen) /* I - Size of resource buffer */
822{
a4d04587 823 httpSeparateURI(HTTP_URI_CODING_ALL, uri, scheme, schemelen, username,
824 usernamelen, host, hostlen, port, resource, resourcelen);
ef416fc2 825}
826
827
828/*
829 * 'httpSeparateURI()' - Separate a Universal Resource Identifier into its
830 * components.
831 *
832 * @since CUPS 1.2@
833 */
834
835http_uri_status_t /* O - Result of separation */
a4d04587 836httpSeparateURI(
837 http_uri_coding_t decoding, /* I - Decoding flags */
838 const char *uri, /* I - Universal Resource Identifier */
839 char *scheme, /* O - Scheme (http, https, etc.) */
840 int schemelen, /* I - Size of scheme buffer */
841 char *username, /* O - Username */
842 int usernamelen, /* I - Size of username buffer */
843 char *host, /* O - Hostname */
844 int hostlen, /* I - Size of hostname buffer */
845 int *port, /* O - Port number to use */
846 char *resource, /* O - Resource/filename */
847 int resourcelen) /* I - Size of resource buffer */
ef416fc2 848{
849 char *ptr, /* Pointer into string... */
850 *end; /* End of string */
851 const char *sep; /* Separator character */
852 http_uri_status_t status; /* Result of separation */
853
854
855 /*
856 * Initialize everything to blank...
857 */
858
859 if (scheme && schemelen > 0)
860 *scheme = '\0';
861
862 if (username && usernamelen > 0)
863 *username = '\0';
864
865 if (host && hostlen > 0)
866 *host = '\0';
867
868 if (port)
869 *port = 0;
870
871 if (resource && resourcelen > 0)
872 *resource = '\0';
873
874 /*
875 * Range check input...
876 */
877
878 if (!uri || !port || !scheme || schemelen <= 0 || !username ||
879 usernamelen <= 0 || !host || hostlen <= 0 || !resource ||
880 resourcelen <= 0)
881 return (HTTP_URI_BAD_ARGUMENTS);
882
883 if (!*uri)
884 return (HTTP_URI_BAD_URI);
885
886 /*
887 * Grab the scheme portion of the URI...
888 */
889
890 status = HTTP_URI_OK;
891
892 if (!strncmp(uri, "//", 2))
893 {
894 /*
895 * Workaround for HP IPP client bug...
896 */
897
898 strlcpy(scheme, "ipp", schemelen);
899 status = HTTP_URI_MISSING_SCHEME;
900 }
901 else if (*uri == '/')
902 {
903 /*
904 * Filename...
905 */
906
907 strlcpy(scheme, "file", schemelen);
908 status = HTTP_URI_MISSING_SCHEME;
909 }
910 else
911 {
912 /*
913 * Standard URI with scheme...
914 */
915
916 for (ptr = scheme, end = scheme + schemelen - 1;
917 *uri && *uri != ':' && ptr < end;)
918 if (isalnum(*uri & 255) || *uri == '-' || *uri == '+' || *uri == '.')
919 *ptr++ = *uri++;
920 else
921 break;
922
923 *ptr = '\0';
924
925 if (*uri != ':')
926 {
927 *scheme = '\0';
928 return (HTTP_URI_BAD_SCHEME);
929 }
930
931 uri ++;
932 }
933
934 /*
935 * Set the default port number...
936 */
937
938 if (!strcmp(scheme, "http"))
939 *port = 80;
940 else if (!strcmp(scheme, "https"))
941 *port = 443;
942 else if (!strcmp(scheme, "ipp"))
943 *port = 631;
944 else if (!strcasecmp(scheme, "lpd"))
945 *port = 515;
946 else if (!strcmp(scheme, "socket")) /* Not yet registered with IANA... */
947 *port = 9100;
948 else if (strcmp(scheme, "file") && strcmp(scheme, "mailto"))
949 status = HTTP_URI_UNKNOWN_SCHEME;
950
951 /*
952 * Now see if we have a hostname...
953 */
954
955 if (!strncmp(uri, "//", 2))
956 {
957 /*
958 * Yes, extract it...
959 */
960
961 uri += 2;
962
963 /*
964 * Grab the username, if any...
965 */
966
967 if ((sep = strpbrk(uri, "@/")) != NULL && *sep == '@')
968 {
969 /*
970 * Get a username:password combo...
971 */
972
a4d04587 973 uri = http_copy_decode(username, uri, usernamelen, "@",
974 decoding & HTTP_URI_CODING_USERNAME);
ef416fc2 975
976 if (!uri)
977 {
978 *username = '\0';
979 return (HTTP_URI_BAD_USERNAME);
980 }
981
982 uri ++;
983 }
984
985 /*
986 * Then the hostname/IP address...
987 */
988
989 if (*uri == '[')
990 {
991 /*
992 * Grab IPv6 address...
993 */
994
995 uri ++;
996 if (!strncmp(uri, "v1.", 3))
997 uri += 3; /* Skip IPvN leader... */
998
a4d04587 999 uri = http_copy_decode(host, uri, hostlen, "]",
1000 decoding & HTTP_URI_CODING_HOSTNAME);
ef416fc2 1001
1002 if (!uri)
1003 {
1004 *host = '\0';
1005 return (HTTP_URI_BAD_HOSTNAME);
1006 }
1007
1008 /*
1009 * Validate value...
1010 */
1011
1012 if (*uri != ']')
1013 {
1014 *host = '\0';
1015 return (HTTP_URI_BAD_HOSTNAME);
1016 }
1017
1018 uri ++;
1019
1020 for (ptr = host; *ptr; ptr ++)
1021 if (*ptr == '+')
1022 {
1023 /*
1024 * Convert zone separator to % and stop here...
1025 */
1026
1027 *ptr = '%';
1028 break;
1029 }
1030 else if (*ptr != ':' && *ptr != '.' && !isxdigit(*ptr & 255))
1031 {
1032 *host = '\0';
1033 return (HTTP_URI_BAD_HOSTNAME);
1034 }
1035 }
1036 else
1037 {
1038 /*
b423cd4c 1039 * Validate the hostname or IPv4 address first...
1040 */
1041
1042 for (ptr = (char *)uri; *ptr; ptr ++)
1043 if (strchr(":?/", *ptr))
1044 break;
1045 else if (!strchr("abcdefghijklmnopqrstuvwxyz"
1046 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
1047 "0123456789"
1048 "-._~"
1049 "%"
2fb76298 1050 "!$&'()*+,;=\\", *ptr))
b423cd4c 1051 {
1052 *host = '\0';
1053 return (HTTP_URI_BAD_HOSTNAME);
1054 }
1055
1056 /*
1057 * Then copy the hostname or IPv4 address to the buffer...
ef416fc2 1058 */
1059
a4d04587 1060 uri = http_copy_decode(host, uri, hostlen, ":?/",
1061 decoding & HTTP_URI_CODING_HOSTNAME);
ef416fc2 1062
1063 if (!uri)
1064 {
1065 *host = '\0';
1066 return (HTTP_URI_BAD_HOSTNAME);
1067 }
ef416fc2 1068 }
1069
1070 /*
1071 * Validate hostname for file scheme - only empty and localhost are
1072 * acceptable.
1073 */
1074
1075 if (!strcmp(scheme, "file") && strcmp(host, "localhost") && host[0])
1076 {
1077 *host = '\0';
1078 return (HTTP_URI_BAD_HOSTNAME);
1079 }
1080
1081 /*
1082 * See if we have a port number...
1083 */
1084
1085 if (*uri == ':')
1086 {
1087 /*
1088 * Yes, collect the port number...
1089 */
1090
1091 *port = strtol(uri + 1, (char **)&uri, 10);
1092
d6ae789d 1093 if (*uri != '/' && *uri)
ef416fc2 1094 {
1095 *port = 0;
1096 return (HTTP_URI_BAD_PORT);
1097 }
1098 }
1099 }
1100
1101 /*
1102 * The remaining portion is the resource string...
1103 */
1104
1105 if (*uri == '?' || !*uri)
1106 {
1107 /*
1108 * Hostname but no path...
1109 */
1110
1111 status = HTTP_URI_MISSING_RESOURCE;
1112 *resource = '/';
fa73b229 1113
1114 /*
a4d04587 1115 * Copy any query string...
fa73b229 1116 */
1117
1118 if (*uri == '?')
a4d04587 1119 uri = http_copy_decode(resource + 1, uri, resourcelen - 1, NULL,
1120 decoding & HTTP_URI_CODING_QUERY);
fa73b229 1121 else
1122 resource[1] = '\0';
ef416fc2 1123 }
1124 else
fa73b229 1125 {
a4d04587 1126 uri = http_copy_decode(resource, uri, resourcelen, "?",
1127 decoding & HTTP_URI_CODING_RESOURCE);
fa73b229 1128
1129 if (uri && *uri == '?')
1130 {
1131 /*
a4d04587 1132 * Concatenate any query string...
fa73b229 1133 */
1134
a4d04587 1135 char *resptr = resource + strlen(resource);
1136
b86bc4cf 1137 uri = http_copy_decode(resptr, uri, resourcelen - (int)(resptr - resource),
a4d04587 1138 NULL, decoding & HTTP_URI_CODING_QUERY);
fa73b229 1139 }
1140 }
ef416fc2 1141
1142 if (!uri)
1143 {
1144 *resource = '\0';
1145 return (HTTP_URI_BAD_RESOURCE);
1146 }
1147
1148 /*
1149 * Return the URI separation status...
1150 */
1151
1152 return (status);
1153}
1154
1155
1156/*
1157 * 'httpStatus()' - Return a short string describing a HTTP status code.
9f5eb9be
MS
1158 *
1159 * The returned string is localized to the current POSIX locale and is based
1160 * on the status strings defined in RFC 2616.
ef416fc2 1161 */
1162
9f5eb9be 1163const char * /* O - Localized status string */
ef416fc2 1164httpStatus(http_status_t status) /* I - HTTP status code */
1165{
9f5eb9be
MS
1166 const char *s; /* Status string */
1167 _cups_globals_t *cg = _cupsGlobals(); /* Global data */
1168
1169
1170 if (!cg->lang_default)
1171 cg->lang_default = cupsLangDefault();
1172
ef416fc2 1173 switch (status)
1174 {
1175 case HTTP_CONTINUE :
9f5eb9be
MS
1176 s = _("Continue");
1177 break;
ef416fc2 1178 case HTTP_SWITCHING_PROTOCOLS :
9f5eb9be
MS
1179 s = _("Switching Protocols");
1180 break;
ef416fc2 1181 case HTTP_OK :
9f5eb9be
MS
1182 s = _("OK");
1183 break;
ef416fc2 1184 case HTTP_CREATED :
9f5eb9be
MS
1185 s = _("Created");
1186 break;
ef416fc2 1187 case HTTP_ACCEPTED :
9f5eb9be
MS
1188 s = _("Accepted");
1189 break;
ef416fc2 1190 case HTTP_NO_CONTENT :
9f5eb9be
MS
1191 s = _("No Content");
1192 break;
d6ae789d 1193 case HTTP_MOVED_PERMANENTLY :
9f5eb9be
MS
1194 s = _("Moved Permanently");
1195 break;
d6ae789d 1196 case HTTP_SEE_OTHER :
9f5eb9be
MS
1197 s = _("See Other");
1198 break;
ef416fc2 1199 case HTTP_NOT_MODIFIED :
9f5eb9be
MS
1200 s = _("Not Modified");
1201 break;
ef416fc2 1202 case HTTP_BAD_REQUEST :
9f5eb9be
MS
1203 s = _("Bad Request");
1204 break;
ef416fc2 1205 case HTTP_UNAUTHORIZED :
9f5eb9be
MS
1206 s = _("Unauthorized");
1207 break;
ef416fc2 1208 case HTTP_FORBIDDEN :
9f5eb9be
MS
1209 s = _("Forbidden");
1210 break;
ef416fc2 1211 case HTTP_NOT_FOUND :
9f5eb9be
MS
1212 s = _("Not Found");
1213 break;
ef416fc2 1214 case HTTP_REQUEST_TOO_LARGE :
9f5eb9be
MS
1215 s = _("Request Entity Too Large");
1216 break;
ef416fc2 1217 case HTTP_URI_TOO_LONG :
9f5eb9be
MS
1218 s = _("URI Too Long");
1219 break;
ef416fc2 1220 case HTTP_UPGRADE_REQUIRED :
9f5eb9be
MS
1221 s = _("Upgrade Required");
1222 break;
ef416fc2 1223 case HTTP_NOT_IMPLEMENTED :
9f5eb9be
MS
1224 s = _("Not Implemented");
1225 break;
ef416fc2 1226 case HTTP_NOT_SUPPORTED :
9f5eb9be
MS
1227 s = _("Not Supported");
1228 break;
b423cd4c 1229 case HTTP_EXPECTATION_FAILED :
9f5eb9be
MS
1230 s = _("Expectation Failed");
1231 break;
1232 case HTTP_SERVICE_UNAVAILABLE :
1233 s = _("Service Unavailable");
1234 break;
b423cd4c 1235
ef416fc2 1236 default :
9f5eb9be
MS
1237 s = _("Unknown");
1238 break;
ef416fc2 1239 }
9f5eb9be
MS
1240
1241 return (_cupsLangString(cg->lang_default, s));
ef416fc2 1242}
1243
1244
1245#ifndef HAVE_HSTRERROR
1246/*
1247 * '_cups_hstrerror()' - hstrerror() emulation function for Solaris and others...
1248 */
1249
1250const char * /* O - Error string */
1251_cups_hstrerror(int error) /* I - Error number */
1252{
1253 static const char * const errors[] = /* Error strings */
1254 {
1255 "OK",
1256 "Host not found.",
1257 "Try again.",
1258 "Unrecoverable lookup error.",
1259 "No data associated with name."
1260 };
1261
1262
1263 if (error < 0 || error > 4)
1264 return ("Unknown hostname lookup error.");
1265 else
1266 return (errors[error]);
1267}
1268#endif /* !HAVE_HSTRERROR */
1269
1270
839a51c8
MS
1271/*
1272 * '_httpEncodeURI()' - Percent-encode a HTTP request URI.
1273 */
1274
1275char * /* O - Encoded URI */
1276_httpEncodeURI(char *dst, /* I - Destination buffer */
1277 const char *src, /* I - Source URI */
1278 size_t dstsize) /* I - Size of destination buffer */
1279{
1280 http_copy_encode(dst, src, dst + dstsize - 1, NULL, NULL, 1);
1281 return (dst);
1282}
1283
1284
5eb9da71
MS
1285/*
1286 * '_httpResolveURI()' - Resolve a DNS-SD URI.
1287 */
1288
1289const char * /* O - Resolved URI */
1290_httpResolveURI(
1291 const char *uri, /* I - DNS-SD URI */
1292 char *resolved_uri, /* I - Buffer for resolved URI */
1f0275e3
MS
1293 size_t resolved_size, /* I - Size of URI buffer */
1294 int log) /* I - Log progress to stderr? */
5eb9da71
MS
1295{
1296 char scheme[32], /* URI components... */
1297 userpass[256],
1298 hostname[1024],
1299 resource[1024];
1300 int port;
1f0275e3 1301 http_uri_status_t status; /* URI decode status */
5eb9da71
MS
1302
1303
1f0275e3
MS
1304 DEBUG_printf(("_httpResolveURI(uri=\"%s\", resolved_uri=%p, "
1305 "resolved_size=" CUPS_LLFMT ")\n", uri, resolved_uri,
1306 CUPS_LLCAST resolved_size));
1307
5eb9da71
MS
1308 /*
1309 * Get the device URI...
1310 */
1311
1f0275e3
MS
1312 if ((status = httpSeparateURI(HTTP_URI_CODING_ALL, uri, scheme,
1313 sizeof(scheme), userpass, sizeof(userpass),
1314 hostname, sizeof(hostname), &port, resource,
1315 sizeof(resource))) < HTTP_URI_OK)
1316 {
1317 if (log)
1318 _cupsLangPrintf(stderr, _("Bad device URI \"%s\"!\n"), uri);
1319
1320 DEBUG_printf(("_httpResolveURI: httpSeparateURI returned %d!\n", status));
1321 DEBUG_puts("_httpResolveURI: Returning NULL");
5eb9da71 1322 return (NULL);
1f0275e3 1323 }
5eb9da71
MS
1324
1325 /*
1326 * Resolve it as needed...
1327 */
1328
1329 if (strstr(hostname, "._tcp"))
1330 {
1331#ifdef HAVE_DNSSD
1332 DNSServiceRef ref; /* DNS-SD service reference */
1333 char *regtype, /* Pointer to type in hostname */
1334 *domain; /* Pointer to domain in hostname */
1335 _http_uribuf_t uribuf; /* URI buffer */
1336
1337 /*
1338 * Separate the hostname into service name, registration type, and domain...
1339 */
1340
1f0275e3
MS
1341 for (regtype = strstr(hostname, "._tcp") - 2;
1342 regtype > hostname;
1343 regtype --)
1344 if (regtype[0] == '.' && regtype[1] == '_')
1345 {
1346 /*
1347 * Found ._servicetype in front of ._tcp...
1348 */
1349
1350 *regtype++ = '\0';
1351 break;
1352 }
1353
1354 if (regtype <= hostname)
1355 {
1356 DEBUG_puts("_httpResolveURI: Bad hostname, returning NULL");
1357 return (NULL);
1358 }
5eb9da71
MS
1359
1360 domain = regtype + strlen(regtype) - 1;
1361 if (domain > regtype && *domain == '.')
1362 *domain = '\0';
1363
1364 for (domain = strchr(regtype, '.');
1365 domain;
1366 domain = strchr(domain + 1, '.'))
1367 if (domain[1] != '_')
1368 break;
1369
1370 if (domain)
1371 *domain++ = '\0';
1372
1373 uribuf.buffer = resolved_uri;
1374 uribuf.bufsize = resolved_size;
1375
1376 resolved_uri[0] = '\0';
1377
1f0275e3
MS
1378 DEBUG_printf(("_httpResolveURI: Resolving hostname=\"%s\", regtype=\"%s\", "
1379 "domain=\"%s\"\n", hostname, regtype, domain));
1380 if (log)
1381 {
1382 fputs("STATE: +connecting-to-device\n", stderr);
1383 _cupsLangPrintf(stderr, _("INFO: Looking for \"%s\"...\n"), hostname);
1384 }
1385
5eb9da71
MS
1386 if (DNSServiceResolve(&ref, 0, 0, hostname, regtype, domain,
1387 resolve_callback,
1388 &uribuf) == kDNSServiceErr_NoError)
1389 {
1390 if (DNSServiceProcessResult(ref) != kDNSServiceErr_NoError &&
1391 resolved_uri[0])
1392 uri = NULL;
1393 else
1394 uri = resolved_uri;
1395
1396 DNSServiceRefDeallocate(ref);
1397 }
1398 else
1f0275e3
MS
1399 uri = NULL;
1400
1401 if (log)
1402 fputs("STATE: -connecting-to-device\n", stderr);
1403
1404#else
1405 /*
1406 * No DNS-SD support...
1407 */
5eb9da71
MS
1408
1409 uri = NULL;
1f0275e3
MS
1410#endif /* HAVE_DNSSD */
1411
1412 if (log && !uri)
1413 _cupsLangPuts(stderr, _("Unable to find printer!\n"));
5eb9da71
MS
1414 }
1415
1f0275e3
MS
1416 DEBUG_printf(("_httpResolveURI: Returning \"%s\"\n", uri));
1417
5eb9da71
MS
1418 return (uri);
1419}
1420
1421
ef416fc2 1422/*
1423 * 'http_copy_decode()' - Copy and decode a URI.
1424 */
1425
1426static const char * /* O - New source pointer or NULL on error */
1427http_copy_decode(char *dst, /* O - Destination buffer */
1428 const char *src, /* I - Source pointer */
1429 int dstsize, /* I - Destination size */
a4d04587 1430 const char *term, /* I - Terminating characters */
1431 int decode) /* I - Decode %-encoded values */
ef416fc2 1432{
1433 char *ptr, /* Pointer into buffer */
1434 *end; /* End of buffer */
1435 int quoted; /* Quoted character */
1436
1437
1438 /*
1439 * Copy the src to the destination until we hit a terminating character
1440 * or the end of the string.
1441 */
1442
e00b005a 1443 for (ptr = dst, end = dst + dstsize - 1;
1444 *src && (!term || !strchr(term, *src));
1445 src ++)
ef416fc2 1446 if (ptr < end)
1447 {
a4d04587 1448 if (*src == '%' && decode)
ef416fc2 1449 {
1450 if (isxdigit(src[1] & 255) && isxdigit(src[2] & 255))
1451 {
1452 /*
1453 * Grab a hex-encoded character...
1454 */
1455
1456 src ++;
1457 if (isalpha(*src))
1458 quoted = (tolower(*src) - 'a' + 10) << 4;
1459 else
1460 quoted = (*src - '0') << 4;
1461
1462 src ++;
1463 if (isalpha(*src))
1464 quoted |= tolower(*src) - 'a' + 10;
1465 else
1466 quoted |= *src - '0';
1467
1468 *ptr++ = quoted;
1469 }
1470 else
1471 {
1472 /*
1473 * Bad hex-encoded character...
1474 */
1475
1476 *ptr = '\0';
1477 return (NULL);
1478 }
1479 }
1480 else
1481 *ptr++ = *src;
1482 }
1483
1484 *ptr = '\0';
1485
1486 return (src);
1487}
1488
1489
1490/*
1491 * 'http_copy_encode()' - Copy and encode a URI.
1492 */
1493
1494static char * /* O - End of current URI */
1495http_copy_encode(char *dst, /* O - Destination buffer */
1496 const char *src, /* I - Source pointer */
1497 char *dstend, /* I - End of destination buffer */
a4d04587 1498 const char *reserved, /* I - Extra reserved characters */
1499 const char *term, /* I - Terminating characters */
1500 int encode) /* I - %-encode reserved chars? */
ef416fc2 1501{
ac884b6a 1502 static const char hex[] = "0123456789ABCDEF";
ef416fc2 1503
1504
1505 while (*src && dst < dstend)
1506 {
a4d04587 1507 if (term && *src == *term)
1508 return (dst);
1509
1510 if (encode && (*src == '%' || *src <= ' ' || *src & 128 ||
1511 (reserved && strchr(reserved, *src))))
ef416fc2 1512 {
1513 /*
1514 * Hex encode reserved characters...
1515 */
1516
1517 if ((dst + 2) >= dstend)
1518 break;
1519
1520 *dst++ = '%';
1521 *dst++ = hex[(*src >> 4) & 15];
1522 *dst++ = hex[*src & 15];
1523
1524 src ++;
1525 }
1526 else
1527 *dst++ = *src++;
1528 }
1529
839a51c8
MS
1530 *dst = '\0';
1531
ef416fc2 1532 if (*src)
1533 return (NULL);
1534 else
1535 return (dst);
1536}
1537
1538
5eb9da71
MS
1539#ifdef HAVE_DNSSD
1540/*
1541 * 'resolve_callback()' - Build a device URI for the given service name.
1542 */
1543
1544static void
1545resolve_callback(
1546 DNSServiceRef sdRef, /* I - Service reference */
1547 DNSServiceFlags flags, /* I - Results flags */
1548 uint32_t interfaceIndex, /* I - Interface number */
1549 DNSServiceErrorType errorCode, /* I - Error, if any */
1550 const char *fullName, /* I - Full service name */
1551 const char *hostTarget, /* I - Hostname */
1552 uint16_t port, /* I - Port number */
1553 uint16_t txtLen, /* I - Length of TXT record */
1554 const unsigned char *txtRecord, /* I - TXT record data */
1555 void *context) /* I - Pointer to URI buffer */
1556{
1557 const char *scheme; /* URI scheme */
1558 char rp[257]; /* Remote printer */
1559 const void *value; /* Value from TXT record */
1560 uint8_t valueLen; /* Length of value */
1561 _http_uribuf_t *uribuf; /* URI buffer */
1562
1563
1564 DEBUG_printf(("resolve_callback(sdRef=%p, flags=%x, interfaceIndex=%u, "
1565 "errorCode=%d, fullName=\"%s\", hostTarget=\"%s\", port=%u, "
1566 "txtLen=%u, txtRecord=%p, context=%p)\n", sdRef, flags,
1567 interfaceIndex, errorCode, fullName, hostTarget, port, txtLen,
1568 txtRecord, context));
1569
1570 /*
1571 * Figure out the scheme from the full name...
1572 */
1573
1574 if (strstr(fullName, "._ipp"))
1575 scheme = "ipp";
1576 else if (strstr(fullName, "._printer."))
1577 scheme = "lpd";
1578 else if (strstr(fullName, "._pdl-datastream."))
1579 scheme = "socket";
1580 else
1581 scheme = "riousbprint";
1582
1583 /*
1584 * Extract the "remote printer" key from the TXT record...
1585 */
1586
1587 if ((value = TXTRecordGetValuePtr(txtLen, txtRecord, "rp",
1588 &valueLen)) != NULL)
1589 {
1590 /*
1591 * Convert to resource by concatenating with a leading "/"...
1592 */
1593
1594 rp[0] = '/';
1595 memcpy(rp + 1, value, valueLen);
1596 rp[valueLen + 1] = '\0';
1597 }
1598 else
1599 rp[0] = '\0';
1600
1601 /*
1602 * Assemble the final device URI...
1603 */
1604
1605 uribuf = (_http_uribuf_t *)context;
1606
1607 httpAssembleURI(HTTP_URI_CODING_ALL, uribuf->buffer, uribuf->bufsize, scheme,
1608 NULL, hostTarget, ntohs(port), rp);
1609
1610 DEBUG_printf(("resolve_callback: Resolved URI is \"%s\"...\n",
1611 uribuf->buffer));
1612}
1613#endif /* HAVE_DNSSD */
1614
1615
ef416fc2 1616/*
5eb9da71 1617 * End of "$Id: http-support.c 7583 2008-05-16 17:47:16Z mike $".
ef416fc2 1618 */