]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSMacOSX/mdns_objects/mdns_managed_defaults.h
mDNSResponder-1310.40.42.tar.gz
[apple/mdnsresponder.git] / mDNSMacOSX / mdns_objects / mdns_managed_defaults.h
1 /*
2 * Copyright (c) 2020 Apple Inc. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef __MDNS_MANAGED_DEFAUTS_H__
18 #define __MDNS_MANAGED_DEFAUTS_H__
19
20 #include "mdns_base.h"
21
22 #include <CoreFoundation/CoreFoundation.h>
23 #include <MacTypes.h>
24 #include <stdint.h>
25
26 MDNS_ASSUME_NONNULL_BEGIN
27
28 __BEGIN_DECLS
29
30 /*!
31 * @brief
32 * Creates a defaults dictionary based on a managed defaults domain.
33 *
34 * @param domain
35 * The managed defaults domain as a UTF-8 C string.
36 *
37 * @param out_error
38 * Gets set to an error code that indicates the error that was encountered, if any.
39 *
40 * @result
41 * A reference to a dictionary if successful. Otherwise, NULL.
42 */
43 CFDictionaryRef _Nullable
44 mdns_managed_defaults_create(const char *domain, OSStatus * _Nullable out_error);
45
46 /*!
47 * @brief
48 * Gets the integer value of a key from a defaults dictionary.
49 *
50 * @param defaults
51 * The defaults dictionary.
52 *
53 * @param key
54 * The key.
55 *
56 * @param fallback_value
57 * A fallback value to return if the key is not present in the dictionary, or if the key's value is not an
58 * integer.
59 *
60 * @param out_error
61 * Gets set to an error code that indicates the error that was encountered, if any.
62 *
63 * @result
64 * If the key is present in the dictionary and the key's value is an integer, then the value is returned
65 * after clamping it in the [INT_MIN, INT_MAX] range. Otherwise, the specified fallback value is returned.
66 *
67 */
68 int
69 mdns_managed_defaults_get_int_clamped(CFDictionaryRef defaults, CFStringRef key, int fallback_value,
70 OSStatus * _Nullable out_error);
71
72 __END_DECLS
73
74 MDNS_ASSUME_NONNULL_END
75
76 #endif // __MDNS_MANAGED_DEFAUTS_H__