]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Maintenance: Turn libmiscencoding to C++ (#2325)
authorFrancesco Chemolli <5175948+kinkie@users.noreply.github.com>
Tue, 23 Dec 2025 22:10:40 +0000 (22:10 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Tue, 23 Dec 2025 22:19:29 +0000 (22:19 +0000)
Squid C code does not need `libmiscencoding` anymore.

These changes are limited to making renamed files compile cleanly using
a C++ compiler. Library code still needs to be updated to follow best
C++ practices.

CREDITS
include/base64.h
include/rfc1738.h
include/rfc2617.h
lib/Makefile.am
lib/base64.cc [moved from lib/base64.c with 99% similarity]
lib/md5-test.cc [moved from lib/md5-test.c with 100% similarity]
lib/md5.cc [moved from lib/md5.c with 99% similarity]
lib/rfc1738.cc [moved from lib/rfc1738.c with 100% similarity]
lib/rfc2617.cc [moved from lib/rfc2617.c with 100% similarity]
lib/tests/testRFC1738.cc

diff --git a/CREDITS b/CREDITS
index 4ccb7162bf1de81f4e04fc8c21be5c208cc75b89..bf3058ad127adc8c0fc1db72b23841a63c9a2237 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -501,7 +501,7 @@ lib/snmplib/snmp_vars.c:
 ==============================================================================
 
 include/base64.h:
-lib/base64.c:
+lib/base64.cc:
 
 /*
    Copyright (C) 2002 Niels Möller, Dan Egnor
@@ -545,7 +545,7 @@ lib/heap.c:
 ==============================================================================
 
 include/md5.h,
-lib/md5.c:
+lib/md5.cc:
 
  * The algorithm is due to Ron Rivest.  This code was
  * written by Colin Plumb in 1993, no copyright is claimed.
@@ -582,7 +582,7 @@ SOFTWARE.
 ==============================================================================
 
 include/rfc2617.h,
-lib/rfc2617.c:
+lib/rfc2617.cc:
 
  * The source in this file is derived from the reference implementation
  * in RFC 2617.
@@ -624,7 +624,7 @@ include/snmp_util.h:
 
 ==============================================================================
 
-lib/base64.c::base64_encode():
+lib/base64.cc::base64_encode():
 
 Adopted from http://ftp.sunet.se/pub2/gnu/vm/base64-encode.c.
 Modified to work with strings instead of files.
index 08d9f07cd1a8da63b54fc923527bfdc017dcc08c..8505b1f05ad87341153d66d01a5a07fde7a588ed 100644 (file)
    not, see http://www.gnu.org/licenses/.
 */
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 /* Base64 encoding */
 
 /* Maximum length of output for base64_encode_update. NOTE: Doesn't
@@ -158,10 +154,6 @@ base64_decode_update(struct base64_decode_ctx *ctx,
 int
 base64_decode_final(struct base64_decode_ctx *ctx);
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif /* HAVE_NETTLE_BASE64_H */
 
 /// Calculate the buffer size required to hold the encoded form of
index 1d6b5e6d55094942dd5645974a1a96bc3870a0c8..c7d7edb328b6cc33b321609b34939b0364d25fb3 100644 (file)
@@ -9,10 +9,6 @@
 #ifndef SQUID_INCLUDE_RFC1738_H
 #define SQUID_INCLUDE_RFC1738_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 /* Encoder rfc1738_do_escape flag values. */
 #define RFC1738_ESCAPE_CTRLS       1
 #define RFC1738_ESCAPE_UNSAFE      2
@@ -64,8 +60,5 @@ extern char *rfc1738_do_escape(const char *url, int flags);
  */
 extern void rfc1738_unescape(char *url);
 
-#ifdef __cplusplus
-}
-#endif
 #endif /* SQUID_INCLUDE_RFC1738_H */
 
index 97884b20808d2a714dc44c04599995cdff900225..60a1910ae507598a5723dd7950573046872c6268 100644 (file)
 #ifndef SQUID_INCLUDE_RFC2617_H
 #define SQUID_INCLUDE_RFC2617_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #define HASHLEN 16
 typedef char HASH[HASHLEN];
 #define HASHHEXLEN 32
@@ -61,8 +57,5 @@ extern void CvtHex(const HASH Bin, HASHHEX Hex);
 
 extern void CvtBin(const HASHHEX Hex, HASH Bin);
 
-#ifdef __cplusplus
-}
-#endif
 #endif /* SQUID_INCLUDE_RFC2617_H */
 
index 2196226d9ed0faf74d257eb307ee57d8d0a7b644..d2094afe61e97f67e84344424051c929b47fc513 100644 (file)
@@ -38,10 +38,10 @@ EXTRA_libmiscutil_la_SOURCES = \
        getopt.c
 
 libmiscencoding_la_SOURCES = \
-       base64.c \
-       md5.c \
-       rfc1738.c \
-       rfc2617.c
+       base64.cc \
+       md5.cc \
+       rfc1738.cc \
+       rfc2617.cc
 
 libmisccontainers_la_SOURCES = \
        hash.cc
similarity index 99%
rename from lib/base64.c
rename to lib/base64.cc
index 3b411d6679080032152b5bd2cff44ce1441fe1ce..0826805a91b4428bf1e12e8edd36e77809b3740c 100644 (file)
@@ -208,7 +208,7 @@ encode_raw(const char *alphabet,
     assert(out == dst);
 }
 
-static const char base64_encode_table[64] =
+static const auto base64_encode_table =
     "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
     "abcdefghijklmnopqrstuvwxyz"
     "0123456789+/";
similarity index 100%
rename from lib/md5-test.c
rename to lib/md5-test.cc
similarity index 99%
rename from lib/md5.c
rename to lib/md5.cc
index 8a1a14551dc6fbe52caca18bec99fce8e30edff3..03572de283c922e763c7e689957933567a89c38b 100644 (file)
--- a/lib/md5.c
@@ -88,7 +88,7 @@ SquidMD5Init(struct SquidMD5Context *ctx)
 void
 SquidMD5Update(struct SquidMD5Context *ctx, const void *_buf, unsigned len)
 {
-    uint8_t const *buf = _buf;
+    auto buf = static_cast<const uint8_t *>(_buf);
     uint32_t t;
 
     /* Update byte count */
@@ -180,7 +180,7 @@ SquidMD5Final(unsigned char digest[16], struct SquidMD5Context *ctx)
 void
 SquidMD5Transform(uint32_t buf[4], uint32_t const in[16])
 {
-    register uint32_t a, b, c, d;
+    uint32_t a, b, c, d;
 
     a = buf[0];
     b = buf[1];
similarity index 100%
rename from lib/rfc1738.c
rename to lib/rfc1738.cc
similarity index 100%
rename from lib/rfc2617.c
rename to lib/rfc2617.cc
index 061a45ad29e397fec3bb8766b1b70f2ff6458412..6eee796ff55f5b5c89641509fdce6c0f396f1ebf 100644 (file)
@@ -13,7 +13,7 @@
 #include <cppunit/extensions/HelperMacros.h>
 
 /* Being a C library code it is best bodily included and tested with C++ type-safe techniques. */
-#include "lib/rfc1738.c"
+#include "lib/rfc1738.cc"
 
 /**
  * Test the URL coder RFC 1738 Engine