libzypp 17.31.1
Digest.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
16#include <iostream>
17#include <sstream>
18
19#ifdef DIGEST_TESTSUITE
20#include <fstream>
21#endif
22
23#include <zypp/Digest.h>
24#include <zypp/base/PtrTypes.h>
25
26using std::endl;
27
28namespace zypp {
29
31 { return false; }
33 bool DigestReport::askUserToAccepUnknownDigest( const Pathname &file, const std::string &name )
34 { return false; }
36 bool DigestReport::askUserToAcceptWrongDigest( const Pathname &file, const std::string &requested, const std::string &found )
37 { return false; }
39#ifdef DIGEST_TESTSUITE
40 int main(int argc, char *argv[])
41 {
42 using namespace std;
43 bool openssl = false;
44 unsigned argpos = 1;
45
46 if(argc > 1 && std::string(argv[argpos]) == "--openssl")
47 {
48 openssl = true;
49 ++argpos;
50 }
52 if(argc - argpos < 2)
53 {
54 cerr << "Usage: " << argv[0] << " <DIGESTNAME> <FILE>" << endl;
55 return 1;
56 }
58 const char* digestname = argv[argpos++];
59 const char* fn = argv[argpos++];
60
61 std::ifstream file(fn);
62
63 std::string digest = Digest::digest(digestname, file);
65 if(openssl)
66 cout << digestname << "(" << fn << ")= " << digest << endl;
67 else
68 cout << digest << " " << fn << endl;
69
70 return 0;
71 }
72#endif
73
74} // namespace zypp
std::string digest()
get hex string representation of the digest
Definition: Digest.cc:175
Definition: Arch.h:352
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
virtual bool askUserToAcceptNoDigest(const zypp::Pathname &file)
Definition: Digest.cc:30
virtual bool askUserToAcceptWrongDigest(const Pathname &file, const std::string &requested, const std::string &found)
Definition: Digest.cc:36
virtual bool askUserToAccepUnknownDigest(const Pathname &file, const std::string &name)
Definition: Digest.cc:33