mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-31 17:53:28 -05:00
aba5033604
- switched tests to use the common value of argstream in libretroshare, rather than the one in tests/common - reworked command line arguments in rsinit and retroshare-nogui. - improved passwd hash explanations - improved command-line help. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6559 b45a01b8-16f6-495d-af2f-9b41ad6348cc
65 lines
1.4 KiB
C++
65 lines
1.4 KiB
C++
// COMPILE_LINE: g++ -o test_key_parsing test_key_parsing.cc -g -I../../../openpgpsdk/include -I../ -L../lib ../../../openpgpsdk/src/lib/libops.a -lssl -lcrypto -lbz2
|
|
//
|
|
#include <stdlib.h>
|
|
#include <iostream>
|
|
|
|
extern "C"
|
|
{
|
|
#include <openpgpsdk/std_print.h>
|
|
#include <openpgpsdk/keyring_local.h>
|
|
#include <openpgpsdk/util.h>
|
|
}
|
|
|
|
#include <util/utest.h>
|
|
#include <util/argstream.h>
|
|
|
|
INITTEST() ;
|
|
|
|
int main(int argc,char *argv[])
|
|
{
|
|
try
|
|
{
|
|
// test PGPHandler
|
|
//
|
|
// 0 - init
|
|
|
|
bool armoured = false ;
|
|
std::string keyfile ;
|
|
|
|
argstream as(argc,argv) ;
|
|
|
|
as >> parameter('i',"input-key",keyfile,"input key file.",true)
|
|
>> option('a',"armoured",armoured,"input is armoured")
|
|
>> help() ;
|
|
|
|
as.defaultErrorHandling() ;
|
|
|
|
ops_keyring_t *kr = (ops_keyring_t*)malloc(sizeof(ops_keyring_t)) ;
|
|
kr->nkeys = 0 ;
|
|
kr->nkeys_allocated = 0 ;
|
|
kr->keys = 0 ;
|
|
|
|
CHECK(ops_false != ops_keyring_read_from_file(kr,armoured, keyfile.c_str())) ;
|
|
|
|
for(int i=0;i<kr->nkeys;++i)
|
|
{
|
|
ops_print_public_keydata(&kr->keys[i]) ;
|
|
ops_print_public_keydata_verbose(&kr->keys[i]) ;
|
|
ops_print_public_key(&kr->keys[i].key.pkey) ;
|
|
}
|
|
|
|
ops_list_packets(const_cast<char *>(keyfile.c_str()),armoured,kr,NULL) ;
|
|
|
|
FINALREPORT("Test key parsing") ;
|
|
|
|
return TESTRESULT() ;
|
|
}
|
|
catch(std::exception& e)
|
|
{
|
|
std::cerr << "Caught exception: " << e.what() << std::endl;
|
|
return 1 ;
|
|
}
|
|
}
|
|
|
|
|