]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/testhttp.c
License change: Apache License, Version 2.0.
[thirdparty/cups.git] / cups / testhttp.c
index 00b46de1292b78e49f96e76fc63fb3341c3a2641..a9259d9ad6b42469f6b9259c044ecde6739bd716 100644 (file)
@@ -1,18 +1,10 @@
 /*
- * "$Id$"
- *
  * HTTP test program for CUPS.
  *
  * Copyright 2007-2014 by Apple Inc.
  * Copyright 1997-2006 by Easy Software Products.
  *
- * 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.
  */
 
 /*
@@ -627,15 +619,39 @@ main(int  argc,                           /* I - Number of command-line arguments */
       static const char *trusts[] = { "OK", "Invalid", "Changed", "Expired", "Renewed", "Unknown" };
       if (!httpCopyCredentials(http, &creds))
       {
+       cups_array_t *lcreds;
         http_trust_t trust = httpCredentialsGetTrust(creds, hostname);
 
         httpCredentialsString(creds, info, sizeof(info));
 
+       printf("Count: %d\n", cupsArrayCount(creds));
         printf("Trust: %s\n", trusts[trust]);
         printf("Expiration: %s\n", httpGetDateString(httpCredentialsGetExpiration(creds)));
         printf("IsValidName: %d\n", httpCredentialsAreValidForName(creds, hostname));
         printf("String: \"%s\"\n", info);
 
+       printf("LoadCredentials: %d\n", httpLoadCredentials(NULL, &lcreds, hostname));
+       httpCredentialsString(lcreds, info, sizeof(info));
+       printf("    Count: %d\n", cupsArrayCount(lcreds));
+       printf("    String: \"%s\"\n", info);
+
+        if (lcreds && cupsArrayCount(creds) == cupsArrayCount(lcreds))
+        {
+          http_credential_t    *cred, *lcred;
+
+          for (i = 1, cred = (http_credential_t *)cupsArrayFirst(creds), lcred = (http_credential_t *)cupsArrayFirst(lcreds);
+               cred && lcred;
+               i ++, cred = (http_credential_t *)cupsArrayNext(creds), lcred = (http_credential_t *)cupsArrayNext(lcreds))
+          {
+            if (cred->datalen != lcred->datalen)
+              printf("    Credential #%d: Different lengths (saved=%d, current=%d)\n", i, (int)cred->datalen, (int)lcred->datalen);
+            else if (memcmp(cred->data, lcred->data, cred->datalen))
+              printf("    Credential #%d: Different data\n", i);
+            else
+              printf("    Credential #%d: Matches\n", i);
+          }
+        }
+
         if (trust != HTTP_TRUST_OK)
        {
          printf("SaveCredentials: %d\n", httpSaveCredentials(NULL, creds, hostname));
@@ -862,8 +878,3 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
   return (0);
 }
-
-
-/*
- * End of "$Id$".
- */