aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-06-29 17:48:52 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-06-29 17:48:52 +0000
commit6b37827c18302c498d0c4d32c85e5b745b565a7a (patch)
tree27f0b9b744ce40f091d0fc83e4ae1e8d657cc91f
parentc5e5d9f414b4e2144741110fd6b6566780fa31e6 (diff)
downloadpaludis-6b37827c18302c498d0c4d32c85e5b745b565a7a.tar.gz
paludis-6b37827c18302c498d0c4d32c85e5b745b565a7a.tar.xz
Split up digest tools and classes. Move digest classes into paludis/digests/ so that they can be used internally.
-rw-r--r--configure.ac1
-rw-r--r--ebuild/Makefile.am2
-rw-r--r--ebuild/digests/Makefile.am37
-rw-r--r--ebuild/digests/domd5.cc7
-rw-r--r--ebuild/digests/dormd160.cc7
-rw-r--r--ebuild/digests/dosha256.cc7
-rw-r--r--paludis/Makefile.am.m42
-rw-r--r--paludis/digests/Makefile.am41
-rw-r--r--paludis/digests/md5.cc (renamed from ebuild/digests/md5.cc)25
-rw-r--r--paludis/digests/md5.hh (renamed from ebuild/digests/md5.hh)25
-rw-r--r--paludis/digests/md5_TEST.cc (renamed from ebuild/digests/md5_TEST.cc)5
-rw-r--r--paludis/digests/rmd160.cc (renamed from ebuild/digests/rmd160.cc)22
-rw-r--r--paludis/digests/rmd160.hh (renamed from ebuild/digests/rmd160.hh)23
-rw-r--r--paludis/digests/rmd160_TEST.cc (renamed from ebuild/digests/dormd160_TEST.cc)5
-rw-r--r--paludis/digests/sha256.cc (renamed from ebuild/digests/sha256.cc)23
-rw-r--r--paludis/digests/sha256.hh (renamed from ebuild/digests/sha256.hh)24
-rw-r--r--paludis/digests/sha256_TEST.cc (renamed from ebuild/digests/dosha256_TEST.cc)5
17 files changed, 147 insertions, 114 deletions
diff --git a/configure.ac b/configure.ac
index d2680fb..d1718c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -404,6 +404,7 @@ AC_OUTPUT(
paludis/Makefile
paludis/about.hh
paludis/args/Makefile
+ paludis/digests/Makefile
paludis/hashed_containers.hh
paludis/qa/Makefile
paludis/util/Makefile
diff --git a/ebuild/Makefile.am b/ebuild/Makefile.am
index 041af67..a756995 100644
--- a/ebuild/Makefile.am
+++ b/ebuild/Makefile.am
@@ -1,6 +1,6 @@
MAINTAINERCLEANFILES = Makefile.in
CLEANFILES = *~
-SUBDIRS = . utils digests fetchers
+SUBDIRS = . digests fetchers utils
libexecprogdir = $(libexecdir)/paludis/
diff --git a/ebuild/digests/Makefile.am b/ebuild/digests/Makefile.am
index 99b18dd..9a2161f 100644
--- a/ebuild/digests/Makefile.am
+++ b/ebuild/digests/Makefile.am
@@ -9,43 +9,18 @@ libexecprog_PROGRAMS = \
dormd160 \
domd5
-dosha256_SOURCES = \
- sha256.cc \
- sha256.hh \
- dosha256.cc
+dosha256_SOURCES = dosha256.cc
+dosha256_LDADD = $(top_builddir)/paludis/digests/libpaludisdigests.a
-dormd160_SOURCES = \
- rmd160.cc \
- rmd160.hh \
- dormd160.cc
+dormd160_SOURCES = dormd160.cc
+dormd160_LDADD = $(top_builddir)/paludis/digests/libpaludisdigests.a
-domd5_SOURCES = \
- md5.hh \
- md5.cc \
- domd5.cc
+domd5_SOURCES = domd5.cc
+domd5_LDADD = $(top_builddir)/paludis/digests/libpaludisdigests.a
TESTS_ENVIRONMENT = env \
PALUDIS_EBUILD_DIR="$(srcdir)/ebuild/" \
TEST_SCRIPT_DIR="$(srcdir)/" \
bash $(top_srcdir)/test/run_test.sh
-TESTS = dosha256_TEST dormd160_TEST domd5_TEST
-EXTRA_DIST = $(libexecprog_SCRIPTS) dosha256_TEST.cc dormd160_TEST.cc domd5_TEST.cc
-
-check_SCRIPTS =
-check_PROGRAMS = $(TESTS)
-
AM_CXXFLAGS = -I$(top_srcdir)
-
-dosha256_TEST_SOURCES = sha256.cc sha256.hh dosha256_TEST.cc
-dosha256_TEST_CXXFLAGS = -I$(top_srcdir)
-dosha256_TEST_LDADD = $(top_builddir)/test/libtest.a
-
-dormd160_TEST_SOURCES = rmd160.cc rmd160.hh dormd160_TEST.cc
-dormd160_TEST_CXXFLAGS = -I$(top_srcdir)
-dormd160_TEST_LDADD = $(top_builddir)/test/libtest.a
-
-domd5_TEST_SOURCES = md5.cc md5.hh md5_TEST.cc
-domd5_TEST_CXXFLAGS = -I$(top_srcdir)
-domd5_TEST_LDADD = $(top_builddir)/test/libtest.a
-
diff --git a/ebuild/digests/domd5.cc b/ebuild/digests/domd5.cc
index 80c6821..5c6fc29 100644
--- a/ebuild/digests/domd5.cc
+++ b/ebuild/digests/domd5.cc
@@ -17,9 +17,10 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "md5.hh"
+#include <paludis/digests/md5.hh>
#include <iostream>
#include <cstdlib>
+#include <fstream>
int
main(int argc, char * argv[])
@@ -38,12 +39,12 @@ main(int argc, char * argv[])
std::cerr << argv[0] << ": could not open '" << argv[1] << "'" << std::endl;
return EXIT_FAILURE;
}
- md5::MD5 sum(f);
+ paludis::MD5 sum(f);
std::cout << sum.hexsum() << std::endl;
}
else
{
- md5::MD5 sum(std::cin);
+ paludis::MD5 sum(std::cin);
std::cout << sum.hexsum() << std::endl;
}
diff --git a/ebuild/digests/dormd160.cc b/ebuild/digests/dormd160.cc
index b71565c..bc9a81e 100644
--- a/ebuild/digests/dormd160.cc
+++ b/ebuild/digests/dormd160.cc
@@ -17,8 +17,9 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "rmd160.hh"
+#include <paludis/digests/rmd160.hh>
#include <iostream>
+#include <fstream>
#include <cstdlib>
int
@@ -38,12 +39,12 @@ main(int argc, char * argv[])
std::cerr << argv[0] << ": could not open '" << argv[1] << "'" << std::endl;
return EXIT_FAILURE;
}
- rmd160::RMD160 sum(f);
+ paludis::RMD160 sum(f);
std::cout << sum.hexsum() << std::endl;
}
else
{
- rmd160::RMD160 sum(std::cin);
+ paludis::RMD160 sum(std::cin);
std::cout << sum.hexsum() << std::endl;
}
diff --git a/ebuild/digests/dosha256.cc b/ebuild/digests/dosha256.cc
index 09c2478..fe7fcc7 100644
--- a/ebuild/digests/dosha256.cc
+++ b/ebuild/digests/dosha256.cc
@@ -17,9 +17,10 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "sha256.hh"
+#include <paludis/digests/sha256.hh>
#include <iostream>
#include <cstdlib>
+#include <fstream>
int
main(int argc, char * argv[])
@@ -38,12 +39,12 @@ main(int argc, char * argv[])
std::cerr << argv[0] << ": could not open '" << argv[1] << "'" << std::endl;
return EXIT_FAILURE;
}
- sha256::SHA256 sum(f);
+ paludis::SHA256 sum(f);
std::cout << sum.hexsum() << std::endl;
}
else
{
- sha256::SHA256 sum(std::cin);
+ paludis::SHA256 sum(std::cin);
std::cout << sum.hexsum() << std::endl;
}
diff --git a/paludis/Makefile.am.m4 b/paludis/Makefile.am.m4
index 3fa759c..f872a4c 100644
--- a/paludis/Makefile.am.m4
+++ b/paludis/Makefile.am.m4
@@ -40,7 +40,7 @@ DEFS= \
-DDATADIR=\"$(datadir)\"
EXTRA_DIST = about.hh.in Makefile.am.m4 paludis.hh.m4 files.m4 \
hashed_containers.hh.in testscriptlist
-SUBDIRS = util . args qa
+SUBDIRS = digests util . args qa
libpaludis_a_SOURCES = filelist
diff --git a/paludis/digests/Makefile.am b/paludis/digests/Makefile.am
new file mode 100644
index 0000000..7d82bf4
--- /dev/null
+++ b/paludis/digests/Makefile.am
@@ -0,0 +1,41 @@
+MAINTAINERCLEANFILES = Makefile.in
+CLEANFILES = *~
+SUBDIRS = .
+
+libexecprogdir = $(libexecdir)/paludis/digests/
+
+paludis_digests_includedir = $(includedir)/paludis/digests/
+
+paludis_digests_include_HEADERS = \
+ sha256.hh \
+ rmd160.hh \
+ md5.hh
+
+libpaludisdigests_a_SOURCES = \
+ $(paludis_digests_include_HEADERS) \
+ sha256.cc \
+ rmd160.cc \
+ md5.cc
+
+lib_LIBRARIES = libpaludisdigests.a
+
+TESTS = sha256_TEST rmd160_TEST md5_TEST
+EXTRA_DIST = sha256_TEST.cc rmd160_TEST.cc md5_TEST.cc
+
+check_PROGRAMS = $(TESTS)
+
+AM_CXXFLAGS = -I$(top_srcdir)
+
+sha256_TEST_SOURCES = sha256_TEST.cc
+sha256_TEST_CXXFLAGS = -I$(top_srcdir)
+sha256_TEST_LDADD = $(top_builddir)/test/libtest.a libpaludisdigests.a
+
+rmd160_TEST_SOURCES = rmd160_TEST.cc
+rmd160_TEST_CXXFLAGS = -I$(top_srcdir)
+rmd160_TEST_LDADD = $(top_builddir)/test/libtest.a libpaludisdigests.a
+
+md5_TEST_SOURCES = md5_TEST.cc
+md5_TEST_CXXFLAGS = -I$(top_srcdir)
+md5_TEST_LDADD = $(top_builddir)/test/libtest.a libpaludisdigests.a
+
+
diff --git a/ebuild/digests/md5.cc b/paludis/digests/md5.cc
index cad7b9c..b7a4e4a 100644
--- a/ebuild/digests/md5.cc
+++ b/paludis/digests/md5.cc
@@ -17,11 +17,12 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "md5.hh"
-#include <paludis/util/attributes.hh>
+#include <paludis/digests/md5.hh>
#include <sstream>
+#include <istream>
+#include <iomanip>
-using namespace md5;
+using namespace paludis;
/*
* Implemented based upon the description in RFC1321.
@@ -192,6 +193,24 @@ MD5::hexsum() const
return result.str();
}
+int
+MD5::_get(std::istream & stream)
+{
+ char c;
+ if (stream.get(c))
+ {
+ _size += 8;
+ return static_cast<unsigned char>(c);
+ }
+ else if (! _done_one_pad)
+ {
+ _done_one_pad = true;
+ return 0x80;
+ }
+ else
+ return -1;
+}
+
const uint8_t MD5::_s[64] = {
7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
diff --git a/ebuild/digests/md5.hh b/paludis/digests/md5.hh
index fb15578..b1191cf 100644
--- a/ebuild/digests/md5.hh
+++ b/paludis/digests/md5.hh
@@ -20,12 +20,12 @@
#ifndef PALUDIS_GUARD_EBUILD_DIGESTS_MD5_HH
#define PALUDIS_GUARD_EBUILD_DIGESTS_MD5_HH 1
-#include <fstream>
-#include <iomanip>
+#include <iosfwd>
#include <string>
#include <inttypes.h>
+#include <paludis/util/attributes.hh>
-namespace md5
+namespace paludis
{
class MD5
{
@@ -38,30 +38,13 @@ namespace md5
void _update(const uint8_t * const block);
- inline int _get(std::istream & stream) __attribute__((always_inline))
- {
- char c;
- if (stream.get(c))
- {
- _size += 8;
- return static_cast<unsigned char>(c);
- }
- else if (! _done_one_pad)
- {
- _done_one_pad = true;
- return 0x80;
- }
- else
- return -1;
- }
+ inline int _get(std::istream & stream) PALUDIS_ATTRIBUTE((always_inline));
public:
MD5(std::istream & stream);
std::string hexsum() const;
};
-
}
-
#endif
diff --git a/ebuild/digests/md5_TEST.cc b/paludis/digests/md5_TEST.cc
index eeac37e..2b97a3f 100644
--- a/ebuild/digests/md5_TEST.cc
+++ b/paludis/digests/md5_TEST.cc
@@ -17,10 +17,11 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "md5.hh"
+#include <paludis/digests/md5.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
+using namespace paludis;
using namespace test;
namespace
@@ -68,7 +69,7 @@ namespace test_cases
void run()
{
std::stringstream ss(data);
- md5::MD5 s(ss);
+ MD5 s(ss);
TEST_CHECK_EQUAL(s.hexsum(), expected);
}
};
diff --git a/ebuild/digests/rmd160.cc b/paludis/digests/rmd160.cc
index ecbf570..d8973eb 100644
--- a/ebuild/digests/rmd160.cc
+++ b/paludis/digests/rmd160.cc
@@ -20,8 +20,10 @@
#include "rmd160.hh"
#include <paludis/util/attributes.hh>
#include <sstream>
+#include <istream>
+#include <iomanip>
-using namespace rmd160;
+using namespace paludis;
/*
* Implemented based upon the description at:
@@ -169,6 +171,24 @@ RMD160::hexsum() const
return result.str();
}
+int
+RMD160::_get(std::istream & stream)
+{
+ char c;
+ if (stream.get(c))
+ {
+ _size += 8;
+ return static_cast<unsigned char>(c);
+ }
+ else if (! _done_one_pad)
+ {
+ _done_one_pad = true;
+ return 0x80;
+ }
+ else
+ return -1;
+}
+
const uint8_t RMD160::_r[80] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
diff --git a/ebuild/digests/rmd160.hh b/paludis/digests/rmd160.hh
index 2b25c39..590d0b1 100644
--- a/ebuild/digests/rmd160.hh
+++ b/paludis/digests/rmd160.hh
@@ -20,12 +20,12 @@
#ifndef PALUDIS_GUARD_EBUILD_DIGESTS_RMD160_HH
#define PALUDIS_GUARD_EBUILD_DIGESTS_RMD160_HH 1
-#include <fstream>
-#include <iomanip>
+#include <iosfwd>
#include <string>
#include <inttypes.h>
+#include <paludis/util/attributes.hh>
-namespace rmd160
+namespace paludis
{
class RMD160
{
@@ -40,22 +40,7 @@ namespace rmd160
void _update(const uint8_t * const block);
- inline int _get(std::istream & stream) __attribute__((always_inline))
- {
- char c;
- if (stream.get(c))
- {
- _size += 8;
- return static_cast<unsigned char>(c);
- }
- else if (! _done_one_pad)
- {
- _done_one_pad = true;
- return 0x80;
- }
- else
- return -1;
- }
+ inline int _get(std::istream & stream) PALUDIS_ATTRIBUTE((always_inline));
public:
RMD160(std::istream & stream);
diff --git a/ebuild/digests/dormd160_TEST.cc b/paludis/digests/rmd160_TEST.cc
index b17bfc1..0a1d13b 100644
--- a/ebuild/digests/dormd160_TEST.cc
+++ b/paludis/digests/rmd160_TEST.cc
@@ -17,11 +17,12 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "rmd160.hh"
+#include <paludis/digests/rmd160.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
using namespace test;
+using namespace paludis;
namespace
{
@@ -68,7 +69,7 @@ namespace test_cases
void run()
{
std::stringstream ss(data);
- rmd160::RMD160 s(ss);
+ RMD160 s(ss);
TEST_CHECK_EQUAL(s.hexsum(), expected);
}
};
diff --git a/ebuild/digests/sha256.cc b/paludis/digests/sha256.cc
index 909aadc..d2f1a63 100644
--- a/ebuild/digests/sha256.cc
+++ b/paludis/digests/sha256.cc
@@ -19,9 +19,11 @@
#include "sha256.hh"
#include <paludis/util/attributes.hh>
+#include <istream>
+#include <iomanip>
#include <sstream>
-using namespace sha256;
+using namespace paludis;
/*
* Implemented based upon the description at:
@@ -186,9 +188,26 @@ SHA256::hexsum() const
return result.str();
}
+int
+SHA256::_get(std::istream & stream)
+{
+ char c;
+ if (stream.get(c))
+ {
+ _size += 8;
+ return static_cast<unsigned char>(c);
+ }
+ else if (! _done_one_pad)
+ {
+ _done_one_pad = true;
+ return 0x80;
+ }
+ else
+ return -1;
+}
const uint32_t
-sha256::SHA256::_k[64] = {
+paludis::SHA256::_k[64] = {
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
diff --git a/ebuild/digests/sha256.hh b/paludis/digests/sha256.hh
index 0b0e1ec..99c9c5a 100644
--- a/ebuild/digests/sha256.hh
+++ b/paludis/digests/sha256.hh
@@ -20,12 +20,12 @@
#ifndef PALUDIS_GUARD_EBUILD_DIGESTS_SHA256_HH
#define PALUDIS_GUARD_EBUILD_DIGESTS_SHA256_HH 1
-#include <fstream>
-#include <iomanip>
+#include <iosfwd>
#include <string>
+#include <paludis/util/attributes.hh>
#include <inttypes.h>
-namespace sha256
+namespace paludis
{
class SHA256
{
@@ -38,29 +38,13 @@ namespace sha256
void _update(const uint8_t * const block);
- inline int _get(std::istream & stream) __attribute__((always_inline))
- {
- char c;
- if (stream.get(c))
- {
- _size += 8;
- return static_cast<unsigned char>(c);
- }
- else if (! _done_one_pad)
- {
- _done_one_pad = true;
- return 0x80;
- }
- else
- return -1;
- }
+ inline int _get(std::istream & stream) PALUDIS_ATTRIBUTE((always_inline));
public:
SHA256(std::istream & stream);
std::string hexsum() const;
};
-
}
#endif
diff --git a/ebuild/digests/dosha256_TEST.cc b/paludis/digests/sha256_TEST.cc
index 52d37f9..d7f2cab 100644
--- a/ebuild/digests/dosha256_TEST.cc
+++ b/paludis/digests/sha256_TEST.cc
@@ -17,11 +17,12 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "sha256.hh"
+#include <paludis/digests/sha256.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
using namespace test;
+using namespace paludis;
namespace
{
@@ -68,7 +69,7 @@ namespace test_cases
void run()
{
std::stringstream ss(data);
- sha256::SHA256 s(ss);
+ SHA256 s(ss);
TEST_CHECK_EQUAL(s.hexsum(), expected);
}
};