]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/testhttp.c
Load cups into easysw/current.
[thirdparty/cups.git] / cups / testhttp.c
index 69f9595418d2f77f4ba5ef2e087a2f2085262adb..37f850c9b3fa56bc475e5577d7c4554b62e84349 100644 (file)
@@ -1,25 +1,16 @@
 /*
- * "$Id: testhttp.c 4943 2006-01-18 20:30:42Z mike $"
+ * "$Id: testhttp.c 6649 2007-07-11 21:46:42Z mike $"
  *
  *   HTTP test program for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 1997-2005 by Easy Software Products.
+ *   Copyright 2007 by Apple Inc.
+ *   Copyright 1997-2006 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
- *   property of Easy Software Products 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 missing or damaged please contact Easy Software Products
- *   at:
- *
- *       Attn: CUPS Licensing Information
- *       Easy Software Products
- *       44141 Airport View Drive, Suite 204
- *       Hollywood, Maryland 20636 USA
- *
- *       Voice: (301) 373-9600
- *       EMail: cups-info@cups.org
- *         WWW: http://www.cups.org
+ *   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.
  *
@@ -84,6 +75,8 @@ static uri_test_t     uri_tests[] =   /* URI test data */
                            "http", "username:password", "server", "/", 8080, 8080 },
                          { HTTP_URI_OK, "http://username:passwor%64@server:8080/directory/filename",
                            "http", "username:password", "server", "/directory/filename", 8080, 8080 },
+                         { HTTP_URI_OK, "http://[2000::10:100]:631/ipp",
+                           "http", "", "2000::10:100", "/ipp", 631, 631 },
                          { HTTP_URI_OK, "https://username:passwor%64@server/directory/filename",
                            "https", "username:password", "server", "/directory/filename", 443, 0 },
                          { HTTP_URI_OK, "ipp://username:passwor%64@[::1]/ipp",
@@ -94,6 +87,8 @@ static uri_test_t     uri_tests[] =   /* URI test data */
                            "mailto", "", "", "user@domain.com", 0, 0 },
                          { HTTP_URI_OK, "socket://server/",
                            "socket", "", "server", "/", 9100, 0 },
+                         { HTTP_URI_OK, "socket://192.168.1.1:9101/",
+                           "socket", "", "192.168.1.1", "/", 9101, 9101 },
                          { HTTP_URI_OK, "ipp://username:password@[v1.fe80::200:1234:5678:9abc+eth0]:999/ipp",
                            "ipp", "username:password", "fe80::200:1234:5678:9abc%eth0", "/ipp", 999, 999 },
                          { HTTP_URI_OK, "http://server/admin?DEVICE_URI=usb://HP/Photosmart%25202600%2520series?serial=MY53OK70V10400",
@@ -112,6 +107,8 @@ static uri_test_t   uri_tests[] =   /* URI test data */
                          /* Missing resource */
                          { HTTP_URI_MISSING_RESOURCE, "socket://[::192.168.2.1]",
                            "socket", "", "::192.168.2.1", "/", 9100, 0 },
+                         { HTTP_URI_MISSING_RESOURCE, "socket://192.168.1.1:9101",
+                           "socket", "", "192.168.1.1", "/", 9101 },
 
                          /* Bad URI */
                          { HTTP_URI_BAD_URI, "",
@@ -290,7 +287,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
     fputs("httpGetHostname(): ", stdout);
 
-    if (httpGetHostname(hostname, sizeof(hostname)))
+    if (httpGetHostname(NULL, hostname, sizeof(hostname)))
       printf("PASS (%s)\n", hostname);
     else
     {
@@ -307,9 +304,21 @@ main(int  argc,                            /* I - Number of command-line arguments */
     addrlist = httpAddrGetList(hostname, AF_UNSPEC, NULL);
     if (addrlist)
     {
-      for (i = 0, addr = addrlist; addr; i ++, addr = addr->next);
+      for (i = 0, addr = addrlist; addr; i ++, addr = addr->next)
+      {
+        char   numeric[1024];          /* Numeric IP address */
+
+
+       httpAddrString(&(addr->addr), numeric, sizeof(numeric));
+       if (!strcmp(numeric, "UNKNOWN"))
+         break;
+      }
+
+      if (addr)
+        printf("FAIL (bad address for %s)\n", hostname);
+      else
+        printf("PASS (%d address(es) for %s)\n", i, hostname);
 
-      printf("PASS (%d address(es) for %s)\n", i, hostname);
       httpAddrFreeList(addrlist);
     }
     else
@@ -325,7 +334,8 @@ main(int  argc,                             /* I - Number of command-line arguments */
     fputs("httpSeparateURI(): ", stdout);
     for (i = 0, j = 0; i < (int)(sizeof(uri_tests) / sizeof(uri_tests[0])); i ++)
     {
-      uri_status = httpSeparateURI(uri_tests[i].uri, scheme, sizeof(scheme),
+      uri_status = httpSeparateURI(HTTP_URI_CODING_MOST,
+                                  uri_tests[i].uri, scheme, sizeof(scheme),
                                    username, sizeof(username),
                                   hostname, sizeof(hostname), &port,
                                   resource, sizeof(resource));
@@ -390,7 +400,8 @@ main(int  argc,                             /* I - Number of command-line arguments */
           strstr(uri_tests[i].uri, "//"))
       {
         k ++;
-       uri_status = httpAssembleURI(buffer, sizeof(buffer),
+       uri_status = httpAssembleURI(HTTP_URI_CODING_MOST,
+                                    buffer, sizeof(buffer),
                                     uri_tests[i].scheme,
                                     uri_tests[i].username,
                                     uri_tests[i].hostname,
@@ -459,7 +470,8 @@ main(int  argc,                             /* I - Number of command-line arguments */
       continue;
     }
 
-    httpSeparateURI(argv[i], scheme, sizeof(scheme), username, sizeof(username),
+    httpSeparateURI(HTTP_URI_CODING_MOST, argv[i], scheme, sizeof(scheme),
+                    username, sizeof(username),
                     hostname, sizeof(hostname), &port,
                    resource, sizeof(resource));
 
@@ -485,7 +497,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
     length = httpGetLength2(http);
     total  = 0;
 
-    while ((bytes = httpRead(http, buffer, sizeof(buffer))) > 0)
+    while ((bytes = httpRead2(http, buffer, sizeof(buffer))) > 0)
     {
       total += bytes;
       fwrite(buffer, bytes, 1, out);
@@ -494,8 +506,8 @@ main(int  argc,                             /* I - Number of command-line arguments */
         current = time(NULL);
         if (current == start) current ++;
         printf("\r" CUPS_LLFMT "/" CUPS_LLFMT " bytes ("
-              CUPS_LLFMT " bytes/sec)      ", total, length,
-               total / (current - start));
+              CUPS_LLFMT " bytes/sec)      ", CUPS_LLCAST total,
+              CUPS_LLCAST length, CUPS_LLCAST (total / (current - start)));
         fflush(stdout);
       }
     }
@@ -512,5 +524,5 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
 
 /*
- * End of "$Id: testhttp.c 4943 2006-01-18 20:30:42Z mike $".
+ * End of "$Id: testhttp.c 6649 2007-07-11 21:46:42Z mike $".
  */