[cpp-sp] branch main updated: Centralize a copied function into a header.
Scott Cantor
cantor.2 at osu.edu
Thu Dec 5 20:22:41 UTC 2024
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository cpp-sp.
View the commit online:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=aceafd9d6f3e340aabdf54c8486b746d1fded0d9
The following commit(s) were added to refs/heads/main by this push:
new aceafd9d Centralize a copied function into a header.
aceafd9d is described below
commit aceafd9d6f3e340aabdf54c8486b746d1fded0d9
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Dec 5 15:22:37 2024 -0500
Centralize a copied function into a header.
---
shibsp/Makefile.am | 3 ++-
shibsp/handler/impl/StatusHandler.cpp | 13 ++-----------
shibsp/impl/XMLRequestMapper.cpp | 13 ++-----------
shibsp/remoting/impl/ddf.cpp | 11 +----------
shibsp/util/Misc.h | 34 ++++++++++++++++++++++++++++++++++
shibsp/util/URLEncoder.cpp | 11 +----------
6 files changed, 42 insertions(+), 43 deletions(-)
diff --git a/shibsp/Makefile.am b/shibsp/Makefile.am
index df56c005..c4ed8976 100644
--- a/shibsp/Makefile.am
+++ b/shibsp/Makefile.am
@@ -88,7 +88,8 @@ noinst_HEADERS = \
logging/impl/AbstractLoggingService.h \
logging/impl/LoggingServiceSPI.h \
logging/impl/StringUtil.h \
- remoting/impl/SocketListener.h
+ remoting/impl/SocketListener.h \
+ util/Misc.h
libshibsp_la_SOURCES = \
AbstractSPRequest.cpp \
diff --git a/shibsp/handler/impl/StatusHandler.cpp b/shibsp/handler/impl/StatusHandler.cpp
index e7dae096..261bcd48 100644
--- a/shibsp/handler/impl/StatusHandler.cpp
+++ b/shibsp/handler/impl/StatusHandler.cpp
@@ -32,6 +32,7 @@
#include "handler/RemotedHandler.h"
#include "handler/SecuredHandler.h"
#include "util/CGIParser.h"
+#include "util/Misc.h"
#include <sstream>
@@ -79,16 +80,6 @@ namespace shibsp {
return new StatusHandler(p.first, p.second);
}
- static char _x2c(const char *what)
- {
- char digit;
-
- digit = (what[0] >= 'A' ? ((what[0] & 0xdf) - 'A')+10 : (what[0] - '0'));
- digit *= 16;
- digit += (what[1] >= 'A' ? ((what[1] & 0xdf) - 'A')+10 : (what[1] - '0'));
- return(digit);
- }
-
class DummyRequest : public HTTPRequest
{
public:
@@ -147,7 +138,7 @@ namespace shibsp {
++slash;
if (!isxdigit(*slash) || !isxdigit(*(slash+1)))
throw invalid_argument("Bad request, contained unsupported encoded characters.");
- m_uri += _x2c(slash);
+ m_uri += x2c(slash);
++slash;
}
++slash;
diff --git a/shibsp/impl/XMLRequestMapper.cpp b/shibsp/impl/XMLRequestMapper.cpp
index 7f09b76e..fbab8c7e 100644
--- a/shibsp/impl/XMLRequestMapper.cpp
+++ b/shibsp/impl/XMLRequestMapper.cpp
@@ -30,6 +30,7 @@
#include "SPRequest.h"
#include "util/CGIParser.h"
#include "util/DOMPropertySet.h"
+#include "util/Misc.h"
#include "util/SPConstants.h"
#include <algorithm>
@@ -365,16 +366,6 @@ Override::Override(bool unicodeAware, const DOMElement* e, Category& log, const
}
}
-static char _x2c(const char *what)
-{
- char digit;
-
- digit = (what[0] >= 'A' ? ((what[0] & 0xdf) - 'A')+10 : (what[0] - '0'));
- digit *= 16;
- digit += (what[1] >= 'A' ? ((what[1] & 0xdf) - 'A')+10 : (what[1] - '0'));
- return(digit);
-}
-
const Override* Override::locate(const HTTPRequest& request) const
{
// This function is confusing because it's *not* recursive.
@@ -402,7 +393,7 @@ const Override* Override::locate(const HTTPRequest& request) const
++path;
if (!isxdigit(*path) || !isxdigit(*(path+1)))
throw ConfigurationException("Bad request URI, contained unsupported encoded characters.");
- dup += _x2c(path);
+ dup += x2c(path);
++path;
}
++path;
diff --git a/shibsp/remoting/impl/ddf.cpp b/shibsp/remoting/impl/ddf.cpp
index 166e8616..0f416853 100644
--- a/shibsp/remoting/impl/ddf.cpp
+++ b/shibsp/remoting/impl/ddf.cpp
@@ -26,6 +26,7 @@
#include "internal.h"
#include "remoting/ddf.h"
+#include "util/Misc.h"
#include <stdexcept>
#include <iomanip>
@@ -1010,16 +1011,6 @@ SHIBSP_API ostream& shibsp::operator<<(ostream& os, const DDF& obj)
return os;
}
-static char x2c(char *what)
-{
- char digit;
-
- digit = (what[0] >= 'A' ? ((what[0] & 0xdf) - 'A')+10 : (what[0] - '0'));
- digit *= 16;
- digit += (what[1] >= 'A' ? ((what[1] & 0xdf) - 'A')+10 : (what[1] - '0'));
- return(digit);
-}
-
DDF deserialize(istream& is)
{
string line;
diff --git a/shibsp/util/Misc.h b/shibsp/util/Misc.h
new file mode 100644
index 00000000..e38db015
--- /dev/null
+++ b/shibsp/util/Misc.h
@@ -0,0 +1,34 @@
+/**
+ * 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
+ *
+ * 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.
+ */
+
+/**
+ * @file shibsp/util/Misc.h
+ *
+ * Miscellaneous inline functions and classes.
+ */
+
+#include <shibsp/base.h>
+
+namespace shibsp {
+
+ static char x2c(const char* what) {
+ char digit;
+
+ digit = (what[0] >= 'A' ? ((what[0] & 0xdf) - 'A')+10 : (what[0] - '0'));
+ digit *= 16;
+ digit += (what[1] >= 'A' ? ((what[1] & 0xdf) - 'A')+10 : (what[1] - '0'));
+ return(digit);
+ }
+
+};
\ No newline at end of file
diff --git a/shibsp/util/URLEncoder.cpp b/shibsp/util/URLEncoder.cpp
index 59caffb5..00770511 100644
--- a/shibsp/util/URLEncoder.cpp
+++ b/shibsp/util/URLEncoder.cpp
@@ -21,21 +21,12 @@
#include "internal.h"
+#include "util/Misc.h"
#include "util/URLEncoder.h"
using namespace shibsp;
using namespace std;
-static char x2c(char *what)
-{
- char digit;
-
- digit = (what[0] >= 'A' ? ((what[0] & 0xdf) - 'A')+10 : (what[0] - '0'));
- digit *= 16;
- digit += (what[1] >= 'A' ? ((what[1] & 0xdf) - 'A')+10 : (what[1] - '0'));
- return(digit);
-}
-
URLEncoder::URLEncoder()
{
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list