]>
Commit | Line | Data |
---|---|---|
70ad1dc8 A |
1 | /* |
2 | * Copyright (c) 2018 Apple Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * This file contains Original Code and/or Modifications of Original Code | |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. Please obtain a copy of the License at | |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | * file. | |
12 | * | |
13 | * The Original Code and all software distributed under the License are | |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
18 | * Please see the License for the specific language governing rights and | |
19 | * limitations under the License. | |
20 | * | |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
23 | ||
24 | /*! | |
25 | * @header | |
26 | * Darwin-specific additions for FreeBSD APIs. | |
27 | */ | |
28 | #ifndef __DARWIN_BSD_H | |
29 | #define __DARWIN_BSD_H | |
30 | ||
31 | #include <os/base.h> | |
32 | #include <os/api.h> | |
33 | #include <sys/cdefs.h> | |
34 | #include <sys/errno.h> | |
35 | #include <sys/types.h> | |
36 | #include <stdint.h> | |
37 | #include <stdbool.h> | |
38 | ||
e1ee4b85 A |
39 | #if DARWIN_TAPI |
40 | #include "tapi.h" | |
41 | #endif | |
42 | ||
70ad1dc8 A |
43 | __BEGIN_DECLS; |
44 | ||
45 | /*! | |
46 | * @function sysctl_get_data_np | |
47 | * A convenience routine for getting a sysctl(3) property whose size is not | |
48 | * known at compile-time. | |
49 | * | |
50 | * @param mib | |
51 | * An array describing the property to manipulate. This is a "management | |
52 | * information base"-style descriptor, as described in sysctl(3). | |
53 | * | |
54 | * @param mib_cnt | |
55 | * The number of items in the MIB array. | |
56 | * | |
57 | * @param buff | |
58 | * On successful return, a pointer to a newly-allocated buffer. The caller is | |
59 | * responsible for free(3)ing this buffer when it is no longer needed. | |
60 | * | |
61 | * @param buff_len | |
62 | * On successful return, the length of the returned buffer. | |
63 | * | |
64 | * @result | |
65 | * See the sysctl(3) man page for possible return codes. | |
66 | */ | |
67 | DARWIN_API_AVAILABLE_20170407 | |
68 | OS_EXPORT OS_WARN_RESULT OS_NONNULL1 OS_NONNULL3 OS_NONNULL4 | |
69 | errno_t | |
70 | sysctl_get_data_np(int *mib, size_t mib_cnt, void **buff, size_t *buff_len); | |
71 | ||
72 | /*! | |
73 | * @function sysctlbyname_get_data_np | |
74 | * A convenience routine for getting a sysctl(3) property whose size is not | |
75 | * known at compile-time. | |
76 | * | |
77 | * @param mibdesc | |
78 | * An ASCII representation of the MIB vector describing the property to | |
79 | * manipulate. Each element of the vector described is separated by a '.' | |
80 | * character (e.g. "kern.ostype"). | |
81 | * | |
82 | * @param buff | |
83 | * On successful return, a pointer to a newly-allocated buffer. The caller is | |
84 | * responsible for free(3)ing this buffer when it is no longer needed. | |
85 | * | |
86 | * @param buff_len | |
87 | * On successful return, the length of the returned buffer. | |
88 | * | |
89 | * @result | |
90 | * See the sysctl(3) man page for possible return codes. | |
91 | */ | |
92 | DARWIN_API_AVAILABLE_20170407 | |
93 | OS_EXPORT OS_WARN_RESULT OS_NONNULL1 OS_NONNULL2 OS_NONNULL3 | |
94 | errno_t | |
95 | sysctlbyname_get_data_np(const char *mibdesc, void **buff, size_t *buff_len); | |
96 | ||
97 | /*! | |
98 | * @function os_parse_boot_arg_int | |
99 | * A routine for extracting a boot-arg as an integer value that is semantically | |
100 | * similar to the PE_parse_boot_argn() kernel routine. | |
101 | * | |
102 | * @param which | |
103 | * The name of the boot-arg whose value is to be obtained. The caller may pass | |
104 | * NULL to simply check for the existence of a boot-arg. | |
105 | * | |
106 | * @param where | |
107 | * On successful return, the integer value of the given boot-arg. | |
108 | * | |
109 | * @result | |
110 | * A Boolean indicating whether the named argument was found. If the discovered | |
111 | * argument value was not convertible to an integer according to the contract | |
112 | * in strtoll(3), the implementation will return false. | |
113 | * | |
114 | * @discussion | |
115 | * Boot-args are expressed with an '=' sign as a separator between the name and | |
116 | * value of an argument, e.g. "cs_enforcement_disable=1". | |
117 | */ | |
118 | DARWIN_API_AVAILABLE_20170407 | |
119 | OS_EXPORT OS_WARN_RESULT OS_NONNULL1 | |
120 | bool | |
121 | os_parse_boot_arg_int(const char *which, int64_t *where); | |
122 | ||
123 | /*! | |
124 | * @function os_parse_boot_arg_string | |
125 | * A routine for extracting a boot-arg's string value that is semantically | |
126 | * similar to the PE_parse_boot_argn() kernel routine. | |
127 | * | |
128 | * @param which | |
129 | * The name of the boot-arg whose value is to be obtained. | |
130 | * | |
131 | * @param where | |
132 | * The buffer in which to place the extracted value on successful return. The | |
133 | * caller may pass NULL to simply check for the existence of a boot-arg. | |
134 | * | |
135 | * @param maxlen | |
136 | * The length of the {@link where} buffer. May be zero if the caller only wishes | |
137 | * to check for the existence of a boot-arg. | |
138 | * | |
139 | * @result | |
140 | * A Boolean indicating whether the named argument was found. | |
141 | */ | |
142 | DARWIN_API_AVAILABLE_20170407 | |
143 | OS_EXPORT OS_WARN_RESULT OS_NONNULL1 | |
144 | bool | |
145 | os_parse_boot_arg_string(const char *which, char *where, size_t maxlen); | |
146 | ||
147 | __END_DECLS; | |
148 | ||
149 | #endif // __DARWIN_BSD_H |