aboutsummaryrefslogtreecommitdiff
path: root/openssl/agent/pkcs11/url.test.cxx
blob: fda1a6ec3ea866a547713c5fa9cd4a568c0a33fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// file      : openssl/agent/pkcs11/url.test.cxx -*- C++ -*-
// copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
// license   : MIT; see accompanying LICENSE file

#include <iostream>

#include <openssl/agent/pkcs11/url.hxx>

// Usage: argv[0]
//
// Create pkcs11::url objects from stdin lines, and for each of them print its
// string representation to stdout, one per line.
//
int
main ()
{
  using namespace std;
  using namespace openssl;
  using namespace openssl::agent::pkcs11;

  cin.exceptions  (ios::badbit);
  cout.exceptions (ios::failbit | ios::badbit);

  try
  {
    string s;
    while (!eof (getline (cin, s)))
    {
      url u (s);

      // Validate the URL attributes.
      //
      identity idn (u);
      access   acc (u);

      cout << u << endl;
    }

    return 0;
  }
  catch (const exception& e)
  {
    cerr << e << endl;
    return 1;
  }
}