SSPCPP-616 - clean up concatenated string literals
[shibboleth/cpp-opensaml.git] / saml / saml2 / binding / impl / SAML2Redirect.cpp
index 2bd108e..7c2a4a5 100644 (file)
@@ -1,33 +1,37 @@
-/*
- *  Copyright 2001-2007 Internet2
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+/**
+ * Licensed to the University Corporation for Advanced Internet
+ * Development, Inc. (UCAID) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for
+ * additional information regarding copyright ownership.
+ *
+ * UCAID licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the
+ * License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
  *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the License.
  */
 
 /**
  * @file saml/saml2/binding/SAML2Redirect.h
  * 
- * SAML 2.0 HTTP Redirect compression functionality
+ * SAML 2.0 HTTP Redirect compression functionality.
  */
 
 #include "internal.h"
 #include "saml2/binding/SAML2Redirect.h"
 
 #include <zlib.h>
-#include <log4cpp/Category.hh>
+#include <xmltooling/logging.h>
 #include <xmltooling/util/NDC.h>
 
-using namespace log4cpp;
+using namespace xmltooling::logging;
 using namespace std;
 
 namespace {
@@ -49,14 +53,14 @@ char* opensaml::saml2p::deflate(char* in, unsigned int in_len, unsigned int* out
 #ifdef _DEBUG
     xmltooling::NDC ndc("deflate");
 #endif
-    Category& log = Category::getInstance(SAML_LOGCAT".MessageDecoder.SAML2Redirect.zlib");
+    Category& log = Category::getInstance(SAML_LOGCAT ".MessageDecoder.SAML2Redirect.zlib");
 
     z_stream z;
     memset(&z, 0, sizeof(z_stream));
     
     z.zalloc = saml_zalloc;
     z.zfree = saml_zfree;
-    z.opaque = NULL;
+    z.opaque = nullptr;
     z.next_in = (Bytef*)in;
     z.avail_in = in_len;
     *out_len = 0;
@@ -64,7 +68,7 @@ char* opensaml::saml2p::deflate(char* in, unsigned int in_len, unsigned int* out
     int ret = deflateInit2(&z, 9, Z_DEFLATED, -15, 9, Z_DEFAULT_STRATEGY);
     if (ret != Z_OK) {
         log.error("zlib deflateInit2 failed with error code (%d)", ret);
-        return NULL;
+        return nullptr;
     }
   
     int dlen = in_len + (in_len >> 8) + 12;  /* orig_size * 1.001 + 12 */
@@ -89,14 +93,14 @@ unsigned int opensaml::saml2p::inflate(char* in, unsigned int in_len, ostream& o
 #ifdef _DEBUG
     xmltooling::NDC ndc("inflate");
 #endif
-    Category& log = Category::getInstance(SAML_LOGCAT".MessageDecoder.SAML2Redirect.zlib");
+    Category& log = Category::getInstance(SAML_LOGCAT ".MessageDecoder.SAML2Redirect.zlib");
 
     z_stream z;
     memset(&z, 0, sizeof(z_stream));
     
     z.zalloc = saml_zalloc;
     z.zfree = saml_zfree;
-    z.opaque = NULL;
+    z.opaque = nullptr;
     z.next_in = (Bytef*)in;
     z.avail_in = in_len;
   
@@ -113,21 +117,22 @@ unsigned int opensaml::saml2p::inflate(char* in, unsigned int in_len, ostream& o
         return 0;
     }
   
+    size_t diff;
     int iter = 30;
     while (--iter) {  /* Make sure we can never be caught in infinite loop */
         ret = inflate(&z, Z_SYNC_FLUSH);
         switch (ret) {
             case Z_STREAM_END:
-                ret = z.next_out - buf;
+                diff = z.next_out - buf;
                 z.next_out = buf;
-                while (ret--)
+                while (diff--)
                     out << *(z.next_out++);
                 goto done;
                 
             case Z_OK:  /* avail_out should be 0 now. Time to dump the buffer. */
-                ret = z.next_out - buf;
+                diff = z.next_out - buf;
                 z.next_out = buf;
-                while (ret--)
+                while (diff--)
                     out << *(z.next_out++);
                 memset(buf, 0, dlen);
                 z.next_out = buf;