libzypp: zypp/Digest.cc Source File

libzypp 17.38.7

Digest.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
14
15
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-core/base/PtrTypes.h>
25
26using std::endl;
27
28namespace zypp {
29
30 bool DigestReport::askUserToAcceptNoDigest( const zypp::Pathname &file )
31 { return false; }
32
33 bool DigestReport::askUserToAccepUnknownDigest( const Pathname &file, const std::string &name )
34 { return false; }
35
36 bool DigestReport::askUserToAcceptWrongDigest( const Pathname &file, const std::string &requested, const std::string &found )
37 { return false; }
38
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 }
51
52 if(argc - argpos < 2)
53 {
54 cerr << "Usage: " << argv[0] << " <DIGESTNAME> <FILE>" << endl;
55 return 1;
56 }
57
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);
64
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
PtrTypes.h
zypp::Digest::digest
std::string digest()
get hex string representation of the digest
Definition Digest.cc:239
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:48
std
Definition ansi.h:855
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::DigestReport::askUserToAcceptNoDigest
virtual bool askUserToAcceptNoDigest(const zypp::Pathname &file)
Definition Digest.cc:30
zypp::DigestReport::askUserToAcceptWrongDigest
virtual bool askUserToAcceptWrongDigest(const Pathname &file, const std::string &requested, const std::string &found)
Definition Digest.cc:36
zypp::DigestReport::askUserToAccepUnknownDigest
virtual bool askUserToAccepUnknownDigest(const Pathname &file, const std::string &name)
Definition Digest.cc:33
Digest.h