]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/http-support.c
License change: Apache License, Version 2.0.
[thirdparty/cups.git] / cups / http-support.c
index b62ef3596c9b18bdd8977f43cebfdb3ec048e9a2..95135e0493f92cd67957a2424dbdd78a9acef72b 100644 (file)
@@ -1,16 +1,10 @@
 /*
  * HTTP support routines for CUPS.
  *
- * Copyright 2007-2016 by Apple Inc.
+ * Copyright 2007-2017 by Apple Inc.
  * Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file.  If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * This file is subject to the Apple OS-Developed Software exception.
+ * Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
  */
 
 /*
@@ -150,7 +144,7 @@ static void http_resolve_cb(AvahiServiceResolver *resolver,
  * place of traditional string functions whenever you need to create a
  * URI string.
  *
- * @since CUPS 1.2/OS X 10.5@
+ * @since CUPS 1.2/macOS 10.5@
  */
 
 http_uri_status_t                      /* O - URI status */
@@ -430,7 +424,7 @@ httpAssembleURI(
  * this function in place of traditional string functions whenever
  * you need to create a URI string.
  *
- * @since CUPS 1.2/OS X 10.5@
+ * @since CUPS 1.2/macOS 10.5@
  */
 
 http_uri_status_t                      /* O - URI status */
@@ -490,7 +484,7 @@ httpAssembleURIf(
  *
  * The buffer needs to be at least 46 bytes in size.
  *
- * @since CUPS 1.7/OS X 10.9@
+ * @since CUPS 1.7/macOS 10.9@
  */
 
 char *                                 /* I - UUID string */
@@ -502,7 +496,6 @@ httpAssembleUUID(const char *server,        /* I - Server name */
                 size_t     bufsize)    /* I - Size of buffer */
 {
   char                 data[1024];     /* Source string for MD5 */
-  _cups_md5_state_t    md5state;       /* MD5 state */
   unsigned char                md5sum[16];     /* MD5 digest/sum */
 
 
@@ -517,9 +510,7 @@ httpAssembleUUID(const char *server,        /* I - Server name */
            port, name ? name : server, number,
           (unsigned)CUPS_RAND() & 0xffff, (unsigned)CUPS_RAND() & 0xffff);
 
-  _cupsMD5Init(&md5state);
-  _cupsMD5Append(&md5state, (unsigned char *)data, (int)strlen(data));
-  _cupsMD5Finish(&md5state, md5sum);
+  cupsHashData("md5", (unsigned char *)data, strlen(data), md5sum, sizeof(md5sum));
 
  /*
   * Generate the UUID from the MD5...
@@ -543,7 +534,7 @@ httpAssembleUUID(const char *server,        /* I - Server name */
  * This function is deprecated. Use the httpDecode64_2() function instead
  * which provides buffer length arguments.
  *
- * @deprecated@
+ * @deprecated@ @exclude all@
  */
 
 char *                                 /* O - Decoded string */
@@ -566,7 +557,11 @@ httpDecode64(char       *out,              /* I - String to write to */
 /*
  * 'httpDecode64_2()' - Base64-decode a string.
  *
- * @since CUPS 1.1.21/OS X 10.4@
+ * The caller must initialize "outlen" to the maximum size of the decoded
+ * string before calling @code httpDecode64_2@.  On return "outlen" contains the
+ * decoded length of the string.
+ *
+ * @since CUPS 1.1.21/macOS 10.4@
  */
 
 char *                                 /* O  - Decoded string */
@@ -671,7 +666,7 @@ httpDecode64_2(char       *out,             /* I  - String to write to */
  * This function is deprecated. Use the httpEncode64_2() function instead
  * which provides buffer length arguments.
  *
- * @deprecated@
+ * @deprecated@ @exclude all@
  */
 
 char *                                 /* O - Encoded string */
@@ -685,12 +680,12 @@ httpEncode64(char       *out,             /* I - String to write to */
 /*
  * 'httpEncode64_2()' - Base64-encode a string.
  *
- * @since CUPS 1.1.21/OS X 10.4@
+ * @since CUPS 1.1.21/macOS 10.4@
  */
 
 char *                                 /* O - Encoded string */
 httpEncode64_2(char       *out,                /* I - String to write to */
-              int        outlen,       /* I - Size of output string */
+              int        outlen,       /* I - Maximum size of output string */
                const char *in,         /* I - String to read from */
               int        inlen)        /* I - Size of input string */
 {
@@ -778,11 +773,11 @@ httpEncode64_2(char       *out,           /* I - String to write to */
 /*
  * 'httpGetDateString()' - Get a formatted date/time string from a time value.
  *
- * @deprecated@
+ * @deprecated@ @exclude all@
  */
 
 const char *                           /* O - Date/time string */
-httpGetDateString(time_t t)            /* I - UNIX time */
+httpGetDateString(time_t t)            /* I - Time in seconds */
 {
   _cups_globals_t *cg = _cupsGlobals();        /* Pointer to library globals */
 
@@ -794,11 +789,11 @@ httpGetDateString(time_t t)               /* I - UNIX time */
 /*
  * 'httpGetDateString2()' - Get a formatted date/time string from a time value.
  *
- * @since CUPS 1.2/OS X 10.5@
+ * @since CUPS 1.2/macOS 10.5@
  */
 
 const char *                           /* O - Date/time string */
-httpGetDateString2(time_t t,           /* I - UNIX time */
+httpGetDateString2(time_t t,           /* I - Time in seconds */
                    char   *s,          /* I - String buffer */
                   int    slen)         /* I - Size of string buffer */
 {
@@ -819,7 +814,7 @@ httpGetDateString2(time_t t,                /* I - UNIX time */
  * 'httpGetDateTime()' - Get a time value from a formatted date/time string.
  */
 
-time_t                                 /* O - UNIX time */
+time_t                                 /* O - Time in seconds */
 httpGetDateTime(const char *s)         /* I - Date/time string */
 {
   int          i;                      /* Looping var */
@@ -888,7 +883,7 @@ httpGetDateTime(const char *s)              /* I - Date/time string */
  *
  * This function is deprecated; use the httpSeparateURI() function instead.
  *
- * @deprecated@
+ * @deprecated@ @exclude all@
  */
 
 void
@@ -911,8 +906,8 @@ httpSeparate(const char *uri,               /* I - Universal Resource Identifier */
  *
  * This function is deprecated; use the httpSeparateURI() function instead.
  *
- * @since CUPS 1.1.21/OS X 10.4@
- * @deprecated@
+ * @since CUPS 1.1.21/macOS 10.4@
+ * @deprecated@ @exclude all@
  */
 
 void
@@ -936,7 +931,7 @@ httpSeparate2(const char *uri,              /* I - Universal Resource Identifier */
  * 'httpSeparateURI()' - Separate a Universal Resource Identifier into its
  *                       components.
  *
- * @since CUPS 1.2/OS X 10.5@
+ * @since CUPS 1.2/macOS 10.5@
  */
 
 http_uri_status_t                      /* O - Result of separation */
@@ -1419,7 +1414,7 @@ _httpStatus(cups_lang_t   *lang,  /* I - Language */
  * 'httpStatus()' - Return a short string describing a HTTP status code.
  *
  * The returned string is localized to the current POSIX locale and is based
- * on the status strings defined in RFC 2616.
+ * on the status strings defined in RFC 7231.
  */
 
 const char *                           /* O - Localized status string */
@@ -1724,7 +1719,7 @@ _httpResolveURI(
        while (time(NULL) < end_time)
        {
          if (options & _HTTP_RESOLVE_STDERR)
-           _cupsLangPrintFilter(stderr, "INFO", _("Looking for printer..."));
+           _cupsLangPrintFilter(stderr, "INFO", _("Looking for printer."));
 
          if (cb && !(*cb)(context))
          {
@@ -2310,6 +2305,8 @@ http_resolve_cb(
  * Note: This function is needed because avahi_simple_poll_iterate is broken
  *       and always uses a timeout of 0 (!) milliseconds.
  *       (Avahi Ticket #364)
+ *
+ * @private@
  */
 
 static int                             /* O - Number of file descriptors matching */
@@ -2532,7 +2529,7 @@ http_resolve_cb(
   * Assemble the final device URI using the resolved hostname...
   */
 
-  httpAssembleURI(HTTP_URI_CODING_ALL, uribuf->buffer, uribuf->bufsize, scheme,
+  httpAssembleURI(HTTP_URI_CODING_ALL, uribuf->buffer, (int)uribuf->bufsize, scheme,
                   NULL, hostTarget, port, resource);
   DEBUG_printf(("5http_resolve_cb: Resolved URI is \"%s\".", uribuf->buffer));