OpenVPN 3 Core Library
Loading...
Searching...
No Matches
ver.hpp
Go to the documentation of this file.
1
// OpenVPN -- An application to securely tunnel IP networks
2
// over a single port, with support for SSL/TLS-based
3
// session authentication and key exchange,
4
// packet encryption, packet authentication, and
5
// packet compression.
6
//
7
// Copyright (C) 2012- OpenVPN Inc.
8
//
9
// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10
//
11
12
#ifndef OPENVPN_APPLE_VER_H
13
#define OPENVPN_APPLE_VER_H
14
15
#include <errno.h>
16
#include <sys/sysctl.h>
17
18
#include <string>
19
#include <sstream>
20
#include <vector>
21
22
#include <
openvpn/common/split.hpp
>
23
#include <
openvpn/common/number.hpp
>
24
25
namespace
openvpn
{
26
class
AppleVersion
27
{
28
public
:
29
int
major
()
const
30
{
31
return
ver
[0];
32
}
33
int
minor
()
const
34
{
35
return
ver
[1];
36
}
37
int
build
()
const
38
{
39
return
ver
[2];
40
}
41
42
std::string
to_string
()
const
43
{
44
std::ostringstream
os
;
45
os
<<
major
() <<
'.'
<<
minor
() <<
'.'
<<
build
();
46
return
os
.str();
47
}
48
49
protected
:
50
AppleVersion
()
51
{
52
reset
();
53
}
54
55
// verstr should be in the form major.minor.build
56
void
init
(
const
std::string &verstr)
57
{
58
typedef
std::vector<std::string> StringList;
59
reset
();
60
StringList sl;
61
sl.reserve(3);
62
Split::by_char_void<StringList, NullLex, Split::NullLimit>(sl, verstr,
'.'
);
63
for
(
size_t
i = 0; i < 3; ++i)
64
{
65
if
(i < sl.size())
66
parse_number
(sl[i],
ver
[i]);
67
}
68
}
69
70
private
:
71
void
reset
()
72
{
73
ver
[0] =
ver
[1] =
ver
[2] = -1;
74
}
75
76
int
ver
[3];
77
};
78
}
// namespace openvpn
79
80
#endif
openvpn::AppleVersion
Definition
ver.hpp:27
openvpn::AppleVersion::init
void init(const std::string &verstr)
Definition
ver.hpp:56
openvpn::AppleVersion::minor
int minor() const
Definition
ver.hpp:33
openvpn::AppleVersion::AppleVersion
AppleVersion()
Definition
ver.hpp:50
openvpn::AppleVersion::build
int build() const
Definition
ver.hpp:37
openvpn::AppleVersion::to_string
std::string to_string() const
Definition
ver.hpp:42
openvpn::AppleVersion::major
int major() const
Definition
ver.hpp:29
openvpn::AppleVersion::ver
int ver[3]
Definition
ver.hpp:76
openvpn::AppleVersion::reset
void reset()
Definition
ver.hpp:71
openvpn
Definition
ovpncli.cpp:97
openvpn::parse_number
bool parse_number(const char *str, T &retval, const bool nondigit_term=false)
Definition
number.hpp:34
number.hpp
split.hpp
os
std::ostringstream os
Definition
test_capture.cpp:1086
openvpn
apple
ver.hpp
Generated by
1.9.8