preparations for writing a file - forgotten new file; refs #28
parent
da028032e7
commit
7d6d0fdae2
1 changed files with 72 additions and 0 deletions
@ -0,0 +1,72 @@ |
|||||||
|
/*! @file
|
||||||
|
|
||||||
|
@id $Id$ |
||||||
|
*/ |
||||||
|
// 1 2 3 4 5 6 7 8
|
||||||
|
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
||||||
|
|
||||||
|
// #include <pcsc.hxx>
|
||||||
|
// #include <cryptaux.hxx>
|
||||||
|
// #include <openssl.hxx>
|
||||||
|
#include <cardos.hxx> |
||||||
|
|
||||||
|
#include <mrw/vector.hxx> |
||||||
|
#include <mrw/args.hxx> |
||||||
|
|
||||||
|
#include <string> |
||||||
|
#include <memory> |
||||||
|
#include <cctype> |
||||||
|
#include <stdexcept> |
||||||
|
#include <sstream> |
||||||
|
#include <iostream> |
||||||
|
#include <iomanip> |
||||||
|
|
||||||
|
pcsc::Connection c; |
||||||
|
pcsc::Connection::Strings readers; |
||||||
|
|
||||||
|
|
||||||
|
void list() { |
||||||
|
pcsc::Connection c; |
||||||
|
pcsc::Connection::Strings readers(c.scan()); |
||||||
|
std::cout<<"Found "<<readers.size()<<" readers" |
||||||
|
<<(readers.size()?":":".")<<std::endl; |
||||||
|
int i(0); |
||||||
|
for (pcsc::Connection::Strings::iterator r(readers.begin()); |
||||||
|
r!=readers.end(); ++r, ++i) |
||||||
|
std::cout<<i<<": "<<*r<<std::endl; |
||||||
|
} |
||||||
|
|
||||||
|
int main(int argc, char** argv) try { |
||||||
|
int reader(0); |
||||||
|
std::string path("3f005015"); |
||||||
|
mrw::args::parse(argc, argv, "Write data to card.", |
||||||
|
mrw::args::defaults() |
||||||
|
<<mrw::args::decl("l", "list", "list readers", |
||||||
|
mrw::args::decl::param_list() |
||||||
|
<<mrw::args::func(list) |
||||||
|
<<mrw::args::exit()) |
||||||
|
<<mrw::args::decl("r", "reader", "select reader", |
||||||
|
mrw::args::decl::param_list() |
||||||
|
<<mrw::args::param(reader, "num")) |
||||||
|
<<mrw::args::decl("p", "path", "full path", |
||||||
|
mrw::args::decl::param_list() |
||||||
|
<<mrw::args::param(path, "path")) |
||||||
|
); |
||||||
|
pcsc::Connection c; |
||||||
|
pcsc::Connection::Strings readers(c.scan()); |
||||||
|
if (reader<0 || readers.size()<reader) { |
||||||
|
std::cerr<<"reader not found: "<<reader<<std::endl; |
||||||
|
return 1; |
||||||
|
} |
||||||
|
cardos::Commands cmd(c.reader(readers[reader])); |
||||||
|
//cardos::BerValues d(cmd.directory(path));
|
||||||
|
//cardos::BerValues d(cmd.readBerFile(path));
|
||||||
|
//std::cout<<d.print()<<std::endl;
|
||||||
|
std::string res(cmd.readBinary(path)); |
||||||
|
std::cout<<"HEX:"<<std::endl<<crypto::readable(res)<<std::endl; |
||||||
|
std::cout<<"BER:"<<std::endl<<cardos::BerValues(res).print()<<std::endl; |
||||||
|
return 0; |
||||||
|
} catch (std::exception& x) { |
||||||
|
std::cerr<<"ERROR: "<<x.what()<<std::endl; |
||||||
|
return 2; |
||||||
|
} |
Loading…
Reference in new issue