OpenVPN 3 Core Library
Loading...
Searching...
No Matches
scdynstore.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_SCDYNSTORE_H
13#define OPENVPN_APPLE_SCDYNSTORE_H
14
15#include <SystemConfiguration/SCDynamicStore.h>
16
18
19namespace openvpn::CF {
20OPENVPN_CF_WRAP(DynamicStore, dynamic_store_cast, SCDynamicStoreRef, SCDynamicStoreGetTypeID)
21
22template <typename RET, typename KEY>
23inline RET DynamicStoreCopy(const DynamicStore &ds, const KEY &key)
24{
25 String keystr = string(key);
26 return RET(RET::cast(SCDynamicStoreCopyValue(ds(), keystr())));
27}
28
29template <typename KEY>
30inline Dict DynamicStoreCopyDict(const DynamicStore &ds, const KEY &key)
31{
32 Dict dict = DynamicStoreCopy<Dict>(ds, key);
33 if (dict.defined())
34 return dict;
35 else
36 return CF::empty_dict();
37}
38} // namespace openvpn::CF
39
40#endif
#define OPENVPN_CF_WRAP(cls, castmeth, cftype, idmeth)
Definition cf.hpp:26
Dict empty_dict()
Definition cf.hpp:296
Dict DynamicStoreCopyDict(const DynamicStore &ds, const KEY &key)
String string(const char *str)
Definition cf.hpp:221
Dict dict(const void **keys, const void **values, CFIndex numValues)
Definition cf.hpp:276
RET DynamicStoreCopy(const DynamicStore &ds, const KEY &key)