@mcesystems/apple-kit 1.0.23 → 1.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +284 -250
- package/dist/index.js +304 -174
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +303 -173
- package/dist/index.mjs.map +4 -4
- package/dist/resources/bin/darwin/idevice_id +0 -0
- package/dist/resources/bin/darwin/idevicedebug +0 -0
- package/dist/resources/bin/darwin/idevicediagnostics +0 -0
- package/dist/resources/bin/darwin/ideviceinfo +0 -0
- package/dist/resources/bin/darwin/ideviceinstaller +0 -0
- package/dist/resources/bin/darwin/idevicename +0 -0
- package/dist/resources/bin/darwin/idevicepair +0 -0
- package/dist/resources/bin/darwin/idevicescreenshot +0 -0
- package/dist/resources/bin/darwin/idevicesyslog +0 -0
- package/dist/resources/bin/darwin/iproxy +0 -0
- package/dist/resources/bin/darwin/libcrypto.3.dylib +0 -0
- package/dist/resources/bin/darwin/libimobiledevice-1.0.6.dylib +0 -0
- package/dist/resources/bin/darwin/libimobiledevice-glue-1.0.0.dylib +0 -0
- package/dist/resources/bin/darwin/liblzma.5.dylib +0 -0
- package/dist/resources/bin/darwin/libplist-2.0.4.dylib +0 -0
- package/dist/resources/bin/darwin/libssl.3.dylib +0 -0
- package/dist/resources/bin/darwin/libusbmuxd-2.0.7.dylib +0 -0
- package/dist/resources/bin/darwin/libzip.5.dylib +0 -0
- package/dist/resources/bin/darwin/libzstd.1.dylib +0 -0
- package/{resources → dist/resources}/licenses/LGPL-2.1.txt +33 -33
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logic/actions/device.d.ts.map +1 -1
- package/dist/types/logic/actions/proxy.d.ts.map +1 -1
- package/dist/types/logic/appleDeviceKit.d.ts +2 -7
- package/dist/types/logic/appleDeviceKit.d.ts.map +1 -1
- package/package.json +7 -4
- package/scripts/README.md +209 -0
- package/scripts/build-windows.sh.template +134 -0
- package/scripts/export-resources.ts +444 -0
- package/dist/types/utils/portManager.d.ts +0 -68
- package/dist/types/utils/portManager.d.ts.map +0 -1
- package/resources/bin/windows/bz2.dll +0 -0
- package/resources/bin/windows/getopt.dll +0 -0
- package/resources/bin/windows/iconv-2.dll +0 -0
- package/resources/bin/windows/idevice_id.exe +0 -0
- package/resources/bin/windows/ideviceactivation.exe +0 -0
- package/resources/bin/windows/idevicedebug.exe +0 -0
- package/resources/bin/windows/ideviceinfo.exe +0 -0
- package/resources/bin/windows/ideviceinstaller.exe +0 -0
- package/resources/bin/windows/idevicepair.exe +0 -0
- package/resources/bin/windows/imobiledevice.dll +0 -0
- package/resources/bin/windows/iproxy.exe +0 -0
- package/resources/bin/windows/libcrypto-1_1-x64.dll +0 -0
- package/resources/bin/windows/libcurl.dll +0 -0
- package/resources/bin/windows/libideviceactivation-1.0.dll +0 -0
- package/resources/bin/windows/libimobiledevice-1.0.dll +0 -0
- package/resources/bin/windows/libimobiledevice-glue-1.0.dll +0 -0
- package/resources/bin/windows/libplist-2.0.dll +0 -0
- package/resources/bin/windows/libssl-1_1-x64.dll +0 -0
- package/resources/bin/windows/libusb-1.0.dll +0 -0
- package/resources/bin/windows/libusb0.dll +0 -0
- package/resources/bin/windows/libusbmuxd-2.0.dll +0 -0
- package/resources/bin/windows/libxml2.dll +0 -0
- package/resources/bin/windows/lzma.dll +0 -0
- package/resources/bin/windows/pcre.dll +0 -0
- package/resources/bin/windows/pcreposix.dll +0 -0
- package/resources/bin/windows/plist.dll +0 -0
- package/resources/bin/windows/pthreadVC3.dll +0 -0
- package/resources/bin/windows/readline.dll +0 -0
- package/resources/bin/windows/usbmuxd.dll +0 -0
- package/resources/bin/windows/usbmuxd.exe +0 -0
- package/resources/bin/windows/vcruntime140.dll +0 -0
- package/resources/bin/windows/zip.dll +0 -0
- package/resources/bin/windows/zlib1.dll +0 -0
- package/resources/lib/include/libimobiledevice/afc.h +0 -413
- package/resources/lib/include/libimobiledevice/bt_packet_logger.h +0 -156
- package/resources/lib/include/libimobiledevice/companion_proxy.h +0 -212
- package/resources/lib/include/libimobiledevice/debugserver.h +0 -272
- package/resources/lib/include/libimobiledevice/diagnostics_relay.h +0 -228
- package/resources/lib/include/libimobiledevice/file_relay.h +0 -166
- package/resources/lib/include/libimobiledevice/heartbeat.h +0 -137
- package/resources/lib/include/libimobiledevice/house_arrest.h +0 -180
- package/resources/lib/include/libimobiledevice/installation_proxy.h +0 -505
- package/resources/lib/include/libimobiledevice/libimobiledevice.h +0 -444
- package/resources/lib/include/libimobiledevice/lockdown.h +0 -577
- package/resources/lib/include/libimobiledevice/misagent.h +0 -168
- package/resources/lib/include/libimobiledevice/mobile_image_mounter.h +0 -275
- package/resources/lib/include/libimobiledevice/mobileactivation.h +0 -192
- package/resources/lib/include/libimobiledevice/mobilebackup.h +0 -246
- package/resources/lib/include/libimobiledevice/mobilebackup2.h +0 -214
- package/resources/lib/include/libimobiledevice/mobilesync.h +0 -359
- package/resources/lib/include/libimobiledevice/notification_proxy.h +0 -202
- package/resources/lib/include/libimobiledevice/ostrace.h +0 -198
- package/resources/lib/include/libimobiledevice/preboard.h +0 -187
- package/resources/lib/include/libimobiledevice/property_list_service.h +0 -184
- package/resources/lib/include/libimobiledevice/restore.h +0 -179
- package/resources/lib/include/libimobiledevice/reverse_proxy.h +0 -213
- package/resources/lib/include/libimobiledevice/sbservices.h +0 -175
- package/resources/lib/include/libimobiledevice/screenshotr.h +0 -118
- package/resources/lib/include/libimobiledevice/service.h +0 -202
- package/resources/lib/include/libimobiledevice/syslog_relay.h +0 -184
- package/resources/lib/include/libimobiledevice/webinspector.h +0 -137
- package/resources/lib/include/plist/Array.h +0 -80
- package/resources/lib/include/plist/Boolean.h +0 -48
- package/resources/lib/include/plist/Data.h +0 -50
- package/resources/lib/include/plist/Date.h +0 -54
- package/resources/lib/include/plist/Dictionary.h +0 -73
- package/resources/lib/include/plist/Integer.h +0 -54
- package/resources/lib/include/plist/Key.h +0 -49
- package/resources/lib/include/plist/Node.h +0 -57
- package/resources/lib/include/plist/Real.h +0 -48
- package/resources/lib/include/plist/String.h +0 -52
- package/resources/lib/include/plist/Structure.h +0 -62
- package/resources/lib/include/plist/Uid.h +0 -48
- package/resources/lib/include/plist/plist++.h +0 -39
- package/resources/lib/include/plist/plist.h +0 -1448
- package/resources/lib/libimobiledevice-1.0.dll +0 -0
- package/resources/lib/libimobiledevice-1.0.dll.a +0 -0
- package/resources/lib/libplist-2.0.dll +0 -0
- package/resources/lib/libplist-2.0.dll.a +0 -0
|
@@ -1,1448 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file plist/plist.h
|
|
3
|
-
* @brief Main include of libplist
|
|
4
|
-
* \internal
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2012-2023 Nikias Bassen, All Rights Reserved.
|
|
7
|
-
* Copyright (c) 2008-2009 Jonathan Beck, All Rights Reserved.
|
|
8
|
-
*
|
|
9
|
-
* This library is free software; you can redistribute it and/or
|
|
10
|
-
* modify it under the terms of the GNU Lesser General Public
|
|
11
|
-
* License as published by the Free Software Foundation; either
|
|
12
|
-
* version 2.1 of the License, or (at your option) any later version.
|
|
13
|
-
*
|
|
14
|
-
* This library is distributed in the hope that it will be useful,
|
|
15
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
17
|
-
* Lesser General Public License for more details.
|
|
18
|
-
*
|
|
19
|
-
* You should have received a copy of the GNU Lesser General Public
|
|
20
|
-
* License along with this library; if not, write to the Free Software
|
|
21
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
#ifndef LIBPLIST_H
|
|
25
|
-
#define LIBPLIST_H
|
|
26
|
-
|
|
27
|
-
#ifdef __cplusplus
|
|
28
|
-
extern "C"
|
|
29
|
-
{
|
|
30
|
-
#endif
|
|
31
|
-
|
|
32
|
-
#if _MSC_VER && _MSC_VER < 1700
|
|
33
|
-
typedef __int8 int8_t;
|
|
34
|
-
typedef __int16 int16_t;
|
|
35
|
-
typedef __int32 int32_t;
|
|
36
|
-
typedef __int64 int64_t;
|
|
37
|
-
|
|
38
|
-
typedef unsigned __int8 uint8_t;
|
|
39
|
-
typedef unsigned __int16 uint16_t;
|
|
40
|
-
typedef unsigned __int32 uint32_t;
|
|
41
|
-
typedef unsigned __int64 uint64_t;
|
|
42
|
-
|
|
43
|
-
#else
|
|
44
|
-
#include <stdint.h>
|
|
45
|
-
#endif
|
|
46
|
-
|
|
47
|
-
/*{{{ deprecation macros */
|
|
48
|
-
#ifdef __llvm__
|
|
49
|
-
#if defined(__has_extension)
|
|
50
|
-
#if (__has_extension(attribute_deprecated_with_message))
|
|
51
|
-
#ifndef PLIST_WARN_DEPRECATED
|
|
52
|
-
#define PLIST_WARN_DEPRECATED(x) __attribute__((deprecated(x)))
|
|
53
|
-
#endif
|
|
54
|
-
#else
|
|
55
|
-
#ifndef PLIST_WARN_DEPRECATED
|
|
56
|
-
#define PLIST_WARN_DEPRECATED(x) __attribute__((deprecated))
|
|
57
|
-
#endif
|
|
58
|
-
#endif
|
|
59
|
-
#else
|
|
60
|
-
#ifndef PLIST_WARN_DEPRECATED
|
|
61
|
-
#define PLIST_WARN_DEPRECATED(x) __attribute__((deprecated))
|
|
62
|
-
#endif
|
|
63
|
-
#endif
|
|
64
|
-
#elif (__GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 5)))
|
|
65
|
-
#ifndef PLIST_WARN_DEPRECATED
|
|
66
|
-
#define PLIST_WARN_DEPRECATED(x) __attribute__((deprecated(x)))
|
|
67
|
-
#endif
|
|
68
|
-
#elif defined(_MSC_VER)
|
|
69
|
-
#ifndef PLIST_WARN_DEPRECATED
|
|
70
|
-
#define PLIST_WARN_DEPRECATED(x) __declspec(deprecated(x))
|
|
71
|
-
#endif
|
|
72
|
-
#else
|
|
73
|
-
#define PLIST_WARN_DEPRECATED(x)
|
|
74
|
-
#pragma message("WARNING: You need to implement DEPRECATED for this compiler")
|
|
75
|
-
#endif
|
|
76
|
-
/*}}}*/
|
|
77
|
-
|
|
78
|
-
#ifndef PLIST_API
|
|
79
|
-
#ifdef LIBPLIST_STATIC
|
|
80
|
-
#define PLIST_API
|
|
81
|
-
#elif defined(_WIN32)
|
|
82
|
-
#define PLIST_API __declspec(dllimport)
|
|
83
|
-
#else
|
|
84
|
-
#define PLIST_API
|
|
85
|
-
#endif
|
|
86
|
-
#endif
|
|
87
|
-
|
|
88
|
-
#include <sys/types.h>
|
|
89
|
-
#include <stdarg.h>
|
|
90
|
-
#include <stdio.h>
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* libplist : A library to handle Apple Property Lists
|
|
94
|
-
* \defgroup PublicAPI Public libplist API
|
|
95
|
-
*/
|
|
96
|
-
/*@{*/
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* The basic plist abstract data type.
|
|
101
|
-
*/
|
|
102
|
-
typedef void *plist_t;
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* The plist dictionary iterator.
|
|
106
|
-
*/
|
|
107
|
-
typedef void* plist_dict_iter;
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* The plist array iterator.
|
|
111
|
-
*/
|
|
112
|
-
typedef void* plist_array_iter;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* The enumeration of plist node types.
|
|
116
|
-
*/
|
|
117
|
-
typedef enum
|
|
118
|
-
{
|
|
119
|
-
PLIST_NONE =-1, /**< No type */
|
|
120
|
-
PLIST_BOOLEAN, /**< Boolean, scalar type */
|
|
121
|
-
PLIST_INT, /**< Integer, scalar type */
|
|
122
|
-
PLIST_REAL, /**< Real, scalar type */
|
|
123
|
-
PLIST_STRING, /**< ASCII string, scalar type */
|
|
124
|
-
PLIST_ARRAY, /**< Ordered array, structured type */
|
|
125
|
-
PLIST_DICT, /**< Unordered dictionary (key/value pair), structured type */
|
|
126
|
-
PLIST_DATE, /**< Date, scalar type */
|
|
127
|
-
PLIST_DATA, /**< Binary data, scalar type */
|
|
128
|
-
PLIST_KEY, /**< Key in dictionaries (ASCII String), scalar type */
|
|
129
|
-
PLIST_UID, /**< Special type used for 'keyed encoding' */
|
|
130
|
-
PLIST_NULL, /**< NULL type */
|
|
131
|
-
} plist_type;
|
|
132
|
-
|
|
133
|
-
/* for backwards compatibility */
|
|
134
|
-
#define PLIST_UINT PLIST_INT
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* libplist error values
|
|
138
|
-
*/
|
|
139
|
-
typedef enum
|
|
140
|
-
{
|
|
141
|
-
PLIST_ERR_SUCCESS = 0, /**< operation successful */
|
|
142
|
-
PLIST_ERR_INVALID_ARG = -1, /**< one or more of the parameters are invalid */
|
|
143
|
-
PLIST_ERR_FORMAT = -2, /**< the plist contains nodes not compatible with the output format */
|
|
144
|
-
PLIST_ERR_PARSE = -3, /**< parsing of the input format failed */
|
|
145
|
-
PLIST_ERR_NO_MEM = -4, /**< not enough memory to handle the operation */
|
|
146
|
-
PLIST_ERR_IO = -5, /**< I/O error */
|
|
147
|
-
PLIST_ERR_UNKNOWN = -255 /**< an unspecified error occurred */
|
|
148
|
-
} plist_err_t;
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* libplist format types
|
|
152
|
-
*/
|
|
153
|
-
typedef enum
|
|
154
|
-
{
|
|
155
|
-
PLIST_FORMAT_NONE = 0, /**< No format */
|
|
156
|
-
PLIST_FORMAT_XML = 1, /**< XML format */
|
|
157
|
-
PLIST_FORMAT_BINARY = 2, /**< bplist00 format */
|
|
158
|
-
PLIST_FORMAT_JSON = 3, /**< JSON format */
|
|
159
|
-
PLIST_FORMAT_OSTEP = 4, /**< OpenStep "old-style" plist format */
|
|
160
|
-
/* 5-9 are reserved for possible future use */
|
|
161
|
-
PLIST_FORMAT_PRINT = 10, /**< human-readable output-only format */
|
|
162
|
-
PLIST_FORMAT_LIMD = 11, /**< "libimobiledevice" output-only format (ideviceinfo) */
|
|
163
|
-
PLIST_FORMAT_PLUTIL = 12, /**< plutil-style output-only format */
|
|
164
|
-
} plist_format_t;
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* libplist write options
|
|
168
|
-
*/
|
|
169
|
-
typedef enum
|
|
170
|
-
{
|
|
171
|
-
PLIST_OPT_NONE = 0, /**< Default value to use when none of the options is needed. */
|
|
172
|
-
PLIST_OPT_COMPACT = 1 << 0, /**< Use a compact representation (non-prettified). Only valid for #PLIST_FORMAT_JSON and #PLIST_FORMAT_OSTEP. */
|
|
173
|
-
PLIST_OPT_PARTIAL_DATA = 1 << 1, /**< Print 24 bytes maximum of #PLIST_DATA values. If the data is longer than 24 bytes, the first 16 and last 8 bytes will be written. Only valid for #PLIST_FORMAT_PRINT. */
|
|
174
|
-
PLIST_OPT_NO_NEWLINE = 1 << 2, /**< Do not print a final newline character. Only valid for #PLIST_FORMAT_PRINT, #PLIST_FORMAT_LIMD, and #PLIST_FORMAT_PLUTIL. */
|
|
175
|
-
PLIST_OPT_INDENT = 1 << 3, /**< Indent each line of output. Currently only #PLIST_FORMAT_PRINT and #PLIST_FORMAT_LIMD are supported. Use #PLIST_OPT_INDENT_BY() macro to specify the level of indentation. */
|
|
176
|
-
} plist_write_options_t;
|
|
177
|
-
|
|
178
|
-
/** To be used with #PLIST_OPT_INDENT - encodes the level of indentation for OR'ing it into the #plist_write_options_t bitfield. */
|
|
179
|
-
#define PLIST_OPT_INDENT_BY(x) ((x & 0xFF) << 24)
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
/********************************************
|
|
183
|
-
* *
|
|
184
|
-
* Creation & Destruction *
|
|
185
|
-
* *
|
|
186
|
-
********************************************/
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Create a new root plist_t type #PLIST_DICT
|
|
190
|
-
*
|
|
191
|
-
* @return the created plist
|
|
192
|
-
* @sa #plist_type
|
|
193
|
-
*/
|
|
194
|
-
PLIST_API plist_t plist_new_dict(void);
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Create a new root plist_t type #PLIST_ARRAY
|
|
198
|
-
*
|
|
199
|
-
* @return the created plist
|
|
200
|
-
* @sa #plist_type
|
|
201
|
-
*/
|
|
202
|
-
PLIST_API plist_t plist_new_array(void);
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Create a new plist_t type #PLIST_STRING
|
|
206
|
-
*
|
|
207
|
-
* @param val the sting value, encoded in UTF8.
|
|
208
|
-
* @return the created item
|
|
209
|
-
* @sa #plist_type
|
|
210
|
-
*/
|
|
211
|
-
PLIST_API plist_t plist_new_string(const char *val);
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Create a new plist_t type #PLIST_BOOLEAN
|
|
215
|
-
*
|
|
216
|
-
* @param val the boolean value, 0 is false, other values are true.
|
|
217
|
-
* @return the created item
|
|
218
|
-
* @sa #plist_type
|
|
219
|
-
*/
|
|
220
|
-
PLIST_API plist_t plist_new_bool(uint8_t val);
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Create a new plist_t type #PLIST_INT with an unsigned integer value
|
|
224
|
-
*
|
|
225
|
-
* @param val the unsigned integer value
|
|
226
|
-
* @return the created item
|
|
227
|
-
* @sa #plist_type
|
|
228
|
-
* @note The value is always stored as uint64_t internally.
|
|
229
|
-
* Use #plist_get_uint_val or #plist_get_int_val to get the unsigned or signed value.
|
|
230
|
-
*/
|
|
231
|
-
PLIST_API plist_t plist_new_uint(uint64_t val);
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Create a new plist_t type #PLIST_INT with a signed integer value
|
|
235
|
-
*
|
|
236
|
-
* @param val the signed integer value
|
|
237
|
-
* @return the created item
|
|
238
|
-
* @sa #plist_type
|
|
239
|
-
* @note The value is always stored as uint64_t internally.
|
|
240
|
-
* Use #plist_get_uint_val or #plist_get_int_val to get the unsigned or signed value.
|
|
241
|
-
*/
|
|
242
|
-
PLIST_API plist_t plist_new_int(int64_t val);
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Create a new plist_t type #PLIST_REAL
|
|
246
|
-
*
|
|
247
|
-
* @param val the real value
|
|
248
|
-
* @return the created item
|
|
249
|
-
* @sa #plist_type
|
|
250
|
-
*/
|
|
251
|
-
PLIST_API plist_t plist_new_real(double val);
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Create a new plist_t type #PLIST_DATA
|
|
255
|
-
*
|
|
256
|
-
* @param val the binary buffer
|
|
257
|
-
* @param length the length of the buffer
|
|
258
|
-
* @return the created item
|
|
259
|
-
* @sa #plist_type
|
|
260
|
-
*/
|
|
261
|
-
PLIST_API plist_t plist_new_data(const char *val, uint64_t length);
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Create a new plist_t type #PLIST_DATE
|
|
265
|
-
*
|
|
266
|
-
* @param sec The number of seconds since 01/01/1970 (UNIX timestamp)
|
|
267
|
-
* @return the created item
|
|
268
|
-
* @sa #plist_type
|
|
269
|
-
*/
|
|
270
|
-
PLIST_API plist_t plist_new_unix_date(int64_t sec);
|
|
271
|
-
|
|
272
|
-
/**
|
|
273
|
-
* Create a new plist_t type #PLIST_UID
|
|
274
|
-
*
|
|
275
|
-
* @param val the unsigned integer value
|
|
276
|
-
* @return the created item
|
|
277
|
-
* @sa #plist_type
|
|
278
|
-
*/
|
|
279
|
-
PLIST_API plist_t plist_new_uid(uint64_t val);
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Create a new plist_t type #PLIST_NULL
|
|
283
|
-
* @return the created item
|
|
284
|
-
* @sa #plist_type
|
|
285
|
-
* @note This type is not valid for all formats, e.g. the XML format
|
|
286
|
-
* does not support it.
|
|
287
|
-
*/
|
|
288
|
-
PLIST_API plist_t plist_new_null(void);
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Destruct a plist_t node and all its children recursively
|
|
292
|
-
*
|
|
293
|
-
* @param plist the plist to free
|
|
294
|
-
*/
|
|
295
|
-
PLIST_API void plist_free(plist_t plist);
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* Return a copy of passed node and it's children
|
|
299
|
-
*
|
|
300
|
-
* @param node the plist to copy
|
|
301
|
-
* @return copied plist
|
|
302
|
-
*/
|
|
303
|
-
PLIST_API plist_t plist_copy(plist_t node);
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
/********************************************
|
|
307
|
-
* *
|
|
308
|
-
* Array functions *
|
|
309
|
-
* *
|
|
310
|
-
********************************************/
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* Get size of a #PLIST_ARRAY node.
|
|
314
|
-
*
|
|
315
|
-
* @param node the node of type #PLIST_ARRAY
|
|
316
|
-
* @return size of the #PLIST_ARRAY node
|
|
317
|
-
*/
|
|
318
|
-
PLIST_API uint32_t plist_array_get_size(plist_t node);
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* Get the nth item in a #PLIST_ARRAY node.
|
|
322
|
-
*
|
|
323
|
-
* @param node the node of type #PLIST_ARRAY
|
|
324
|
-
* @param n the index of the item to get. Range is [0, array_size[
|
|
325
|
-
* @return the nth item or NULL if node is not of type #PLIST_ARRAY
|
|
326
|
-
*/
|
|
327
|
-
PLIST_API plist_t plist_array_get_item(plist_t node, uint32_t n);
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* Get the index of an item. item must be a member of a #PLIST_ARRAY node.
|
|
331
|
-
*
|
|
332
|
-
* @param node the node
|
|
333
|
-
* @return the node index or UINT_MAX if node index can't be determined
|
|
334
|
-
*/
|
|
335
|
-
PLIST_API uint32_t plist_array_get_item_index(plist_t node);
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* Set the nth item in a #PLIST_ARRAY node.
|
|
339
|
-
* The previous item at index n will be freed using #plist_free
|
|
340
|
-
*
|
|
341
|
-
* @param node the node of type #PLIST_ARRAY
|
|
342
|
-
* @param item the new item at index n. The array is responsible for freeing item when it is no longer needed.
|
|
343
|
-
* @param n the index of the item to get. Range is [0, array_size[. Assert if n is not in range.
|
|
344
|
-
*/
|
|
345
|
-
PLIST_API void plist_array_set_item(plist_t node, plist_t item, uint32_t n);
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* Append a new item at the end of a #PLIST_ARRAY node.
|
|
349
|
-
*
|
|
350
|
-
* @param node the node of type #PLIST_ARRAY
|
|
351
|
-
* @param item the new item. The array is responsible for freeing item when it is no longer needed.
|
|
352
|
-
*/
|
|
353
|
-
PLIST_API void plist_array_append_item(plist_t node, plist_t item);
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* Insert a new item at position n in a #PLIST_ARRAY node.
|
|
357
|
-
*
|
|
358
|
-
* @param node the node of type #PLIST_ARRAY
|
|
359
|
-
* @param item the new item to insert. The array is responsible for freeing item when it is no longer needed.
|
|
360
|
-
* @param n The position at which the node will be stored. Range is [0, array_size[. Assert if n is not in range.
|
|
361
|
-
*/
|
|
362
|
-
PLIST_API void plist_array_insert_item(plist_t node, plist_t item, uint32_t n);
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* Remove an existing position in a #PLIST_ARRAY node.
|
|
366
|
-
* Removed position will be freed using #plist_free.
|
|
367
|
-
*
|
|
368
|
-
* @param node the node of type #PLIST_ARRAY
|
|
369
|
-
* @param n The position to remove. Range is [0, array_size[. Assert if n is not in range.
|
|
370
|
-
*/
|
|
371
|
-
PLIST_API void plist_array_remove_item(plist_t node, uint32_t n);
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
* Remove a node that is a child node of a #PLIST_ARRAY node.
|
|
375
|
-
* node will be freed using #plist_free.
|
|
376
|
-
*
|
|
377
|
-
* @param node The node to be removed from its #PLIST_ARRAY parent.
|
|
378
|
-
*/
|
|
379
|
-
PLIST_API void plist_array_item_remove(plist_t node);
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* Create an iterator of a #PLIST_ARRAY node.
|
|
383
|
-
* The allocated iterator should be freed with the standard free function.
|
|
384
|
-
*
|
|
385
|
-
* @param node The node of type #PLIST_ARRAY
|
|
386
|
-
* @param iter Location to store the iterator for the array.
|
|
387
|
-
*/
|
|
388
|
-
PLIST_API void plist_array_new_iter(plist_t node, plist_array_iter *iter);
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* Increment iterator of a #PLIST_ARRAY node.
|
|
392
|
-
*
|
|
393
|
-
* @param node The node of type #PLIST_ARRAY.
|
|
394
|
-
* @param iter Iterator of the array
|
|
395
|
-
* @param item Location to store the item. The caller must *not* free the
|
|
396
|
-
* returned item. Will be set to NULL when no more items are left
|
|
397
|
-
* to iterate.
|
|
398
|
-
*/
|
|
399
|
-
PLIST_API void plist_array_next_item(plist_t node, plist_array_iter iter, plist_t *item);
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
/********************************************
|
|
403
|
-
* *
|
|
404
|
-
* Dictionary functions *
|
|
405
|
-
* *
|
|
406
|
-
********************************************/
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
* Get size of a #PLIST_DICT node.
|
|
410
|
-
*
|
|
411
|
-
* @param node the node of type #PLIST_DICT
|
|
412
|
-
* @return size of the #PLIST_DICT node
|
|
413
|
-
*/
|
|
414
|
-
PLIST_API uint32_t plist_dict_get_size(plist_t node);
|
|
415
|
-
|
|
416
|
-
/**
|
|
417
|
-
* Create an iterator of a #PLIST_DICT node.
|
|
418
|
-
* The allocated iterator should be freed with the standard free function.
|
|
419
|
-
*
|
|
420
|
-
* @param node The node of type #PLIST_DICT.
|
|
421
|
-
* @param iter Location to store the iterator for the dictionary.
|
|
422
|
-
*/
|
|
423
|
-
PLIST_API void plist_dict_new_iter(plist_t node, plist_dict_iter *iter);
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
* Increment iterator of a #PLIST_DICT node.
|
|
427
|
-
*
|
|
428
|
-
* @param node The node of type #PLIST_DICT
|
|
429
|
-
* @param iter Iterator of the dictionary
|
|
430
|
-
* @param key Location to store the key, or NULL. The caller is responsible
|
|
431
|
-
* for freeing the the returned string.
|
|
432
|
-
* @param val Location to store the value, or NULL. The caller must *not*
|
|
433
|
-
* free the returned value. Will be set to NULL when no more
|
|
434
|
-
* key/value pairs are left to iterate.
|
|
435
|
-
*/
|
|
436
|
-
PLIST_API void plist_dict_next_item(plist_t node, plist_dict_iter iter, char **key, plist_t *val);
|
|
437
|
-
|
|
438
|
-
/**
|
|
439
|
-
* Get key associated key to an item. Item must be member of a dictionary.
|
|
440
|
-
*
|
|
441
|
-
* @param node the item
|
|
442
|
-
* @param key a location to store the key. The caller is responsible for freeing the returned string.
|
|
443
|
-
*/
|
|
444
|
-
PLIST_API void plist_dict_get_item_key(plist_t node, char **key);
|
|
445
|
-
|
|
446
|
-
/**
|
|
447
|
-
* Get the nth item in a #PLIST_DICT node.
|
|
448
|
-
*
|
|
449
|
-
* @param node the node of type #PLIST_DICT
|
|
450
|
-
* @param key the identifier of the item to get.
|
|
451
|
-
* @return the item or NULL if node is not of type #PLIST_DICT. The caller should not free
|
|
452
|
-
* the returned node.
|
|
453
|
-
*/
|
|
454
|
-
PLIST_API plist_t plist_dict_get_item(plist_t node, const char* key);
|
|
455
|
-
|
|
456
|
-
/**
|
|
457
|
-
* Get key node associated to an item. Item must be member of a dictionary.
|
|
458
|
-
*
|
|
459
|
-
* @param node the item
|
|
460
|
-
* @return the key node of the given item, or NULL.
|
|
461
|
-
*/
|
|
462
|
-
PLIST_API plist_t plist_dict_item_get_key(plist_t node);
|
|
463
|
-
|
|
464
|
-
/**
|
|
465
|
-
* Set item identified by key in a #PLIST_DICT node.
|
|
466
|
-
* The previous item identified by key will be freed using #plist_free.
|
|
467
|
-
* If there is no item for the given key a new item will be inserted.
|
|
468
|
-
*
|
|
469
|
-
* @param node the node of type #PLIST_DICT
|
|
470
|
-
* @param item the new item associated to key
|
|
471
|
-
* @param key the identifier of the item to set.
|
|
472
|
-
*/
|
|
473
|
-
PLIST_API void plist_dict_set_item(plist_t node, const char* key, plist_t item);
|
|
474
|
-
|
|
475
|
-
/**
|
|
476
|
-
* Remove an existing position in a #PLIST_DICT node.
|
|
477
|
-
* Removed position will be freed using #plist_free
|
|
478
|
-
*
|
|
479
|
-
* @param node the node of type #PLIST_DICT
|
|
480
|
-
* @param key The identifier of the item to remove. Assert if identifier is not present.
|
|
481
|
-
*/
|
|
482
|
-
PLIST_API void plist_dict_remove_item(plist_t node, const char* key);
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
* Merge a dictionary into another. This will add all key/value pairs
|
|
486
|
-
* from the source dictionary to the target dictionary, overwriting
|
|
487
|
-
* any existing key/value pairs that are already present in target.
|
|
488
|
-
*
|
|
489
|
-
* @param target pointer to an existing node of type #PLIST_DICT
|
|
490
|
-
* @param source node of type #PLIST_DICT that should be merged into target
|
|
491
|
-
*/
|
|
492
|
-
PLIST_API void plist_dict_merge(plist_t *target, plist_t source);
|
|
493
|
-
|
|
494
|
-
/**
|
|
495
|
-
* Get a boolean value from a given #PLIST_DICT entry.
|
|
496
|
-
*
|
|
497
|
-
* The value node can be of type #PLIST_BOOLEAN, but also
|
|
498
|
-
* #PLIST_STRING (either 'true' or 'false'),
|
|
499
|
-
* #PLIST_INT with a numerical value of 0 or >= 1,
|
|
500
|
-
* or #PLIST_DATA with a single byte with a value of 0 or >= 1.
|
|
501
|
-
*
|
|
502
|
-
* @note This function returns 0 if the dictionary does not contain an
|
|
503
|
-
* entry for the given key, if the value node is of any other than
|
|
504
|
-
* the above mentioned type, or has any mismatching value.
|
|
505
|
-
*
|
|
506
|
-
* @param dict A node of type #PLIST_DICT
|
|
507
|
-
* @param key The key to look for in dict
|
|
508
|
-
* @return 0 or 1 depending on the value of the node.
|
|
509
|
-
*/
|
|
510
|
-
PLIST_API uint8_t plist_dict_get_bool(plist_t dict, const char *key);
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* Get a signed integer value from a given #PLIST_DICT entry.
|
|
514
|
-
* The value node can be of type #PLIST_INT, but also
|
|
515
|
-
* #PLIST_STRING with a numerical value as string (decimal or hexadecimal),
|
|
516
|
-
* or #PLIST_DATA with a size of 1, 2, 4, or 8 bytes in little endian byte order.
|
|
517
|
-
*
|
|
518
|
-
* @note This function returns 0 if the dictionary does not contain an
|
|
519
|
-
* entry for the given key, if the value node is of any other than
|
|
520
|
-
* the above mentioned type, or has any mismatching value.
|
|
521
|
-
*
|
|
522
|
-
* @param dict A node of type #PLIST_DICT
|
|
523
|
-
* @param key The key to look for in dict
|
|
524
|
-
* @return Signed integer value depending on the value of the node.
|
|
525
|
-
*/
|
|
526
|
-
PLIST_API int64_t plist_dict_get_int(plist_t dict, const char *key);
|
|
527
|
-
|
|
528
|
-
/**
|
|
529
|
-
* Get an unsigned integer value from a given #PLIST_DICT entry.
|
|
530
|
-
* The value node can be of type #PLIST_INT, but also
|
|
531
|
-
* #PLIST_STRING with a numerical value as string (decimal or hexadecimal),
|
|
532
|
-
* or #PLIST_DATA with a size of 1, 2, 4, or 8 bytes in little endian byte order.
|
|
533
|
-
*
|
|
534
|
-
* @note This function returns 0 if the dictionary does not contain an
|
|
535
|
-
* entry for the given key, if the value node is of any other than
|
|
536
|
-
* the above mentioned type, or has any mismatching value.
|
|
537
|
-
*
|
|
538
|
-
* @param dict A node of type #PLIST_DICT
|
|
539
|
-
* @param key The key to look for in dict
|
|
540
|
-
* @return Signed integer value depending on the value of the node.
|
|
541
|
-
*/
|
|
542
|
-
PLIST_API uint64_t plist_dict_get_uint(plist_t dict, const char *key);
|
|
543
|
-
|
|
544
|
-
/**
|
|
545
|
-
* Copy a node from *source_dict* to *target_dict*.
|
|
546
|
-
* The node is looked up in *source_dict* with given *key*, unless *alt_source_key*
|
|
547
|
-
* is non-NULL, in which case it is looked up with *alt_source_key*.
|
|
548
|
-
* The entry in *target_dict* is **always** created with *key*.
|
|
549
|
-
*
|
|
550
|
-
* @param target_dict The target dictionary to copy to.
|
|
551
|
-
* @param source_dict The source dictionary to copy from.
|
|
552
|
-
* @param key The key for the node to copy.
|
|
553
|
-
* @param alt_source_key The alternative source key for lookup in *source_dict* or NULL.
|
|
554
|
-
*
|
|
555
|
-
* @result PLIST_ERR_SUCCESS on success or PLIST_ERR_INVALID_ARG if the source dictionary does not contain
|
|
556
|
-
* any entry with given key or alt_source_key.
|
|
557
|
-
*/
|
|
558
|
-
PLIST_API plist_err_t plist_dict_copy_item(plist_t target_dict, plist_t source_dict, const char *key, const char *alt_source_key);
|
|
559
|
-
|
|
560
|
-
/**
|
|
561
|
-
* Copy a boolean value from *source_dict* to *target_dict*.
|
|
562
|
-
* The node is looked up in *source_dict* with given *key*, unless *alt_source_key*
|
|
563
|
-
* is non-NULL, in which case it is looked up with *alt_source_key*.
|
|
564
|
-
* The entry in *target_dict* is **always** created with *key*.
|
|
565
|
-
*
|
|
566
|
-
* @note The boolean value from *source_dict* is retrieved with #plist_dict_get_bool,
|
|
567
|
-
* but is **always** created as #PLIST_BOOLEAN in *target_dict*.
|
|
568
|
-
*
|
|
569
|
-
* @param target_dict The target dictionary to copy to.
|
|
570
|
-
* @param source_dict The source dictionary to copy from.
|
|
571
|
-
* @param key The key for the node to copy.
|
|
572
|
-
* @param alt_source_key The alternative source key for lookup in *source_dict* or NULL.
|
|
573
|
-
*
|
|
574
|
-
* @result PLIST_ERR_SUCCESS on success or PLIST_ERR_INVALID_ARG if the source dictionary does not contain
|
|
575
|
-
* any entry with given key or alt_source_key.
|
|
576
|
-
*/
|
|
577
|
-
PLIST_API plist_err_t plist_dict_copy_bool(plist_t target_dict, plist_t source_dict, const char *key, const char *alt_source_key);
|
|
578
|
-
|
|
579
|
-
/**
|
|
580
|
-
* Copy a signed integer value from *source_dict* to *target_dict*.
|
|
581
|
-
* The node is looked up in *source_dict* with given *key*, unless *alt_source_key*
|
|
582
|
-
* is non-NULL, in which case it is looked up with *alt_source_key*.
|
|
583
|
-
* The entry in *target_dict* is **always** created with *key*.
|
|
584
|
-
*
|
|
585
|
-
* @note The signed integer value from *source_dict* is retrieved with #plist_dict_get_int,
|
|
586
|
-
* but is **always** created as #PLIST_INT.
|
|
587
|
-
*
|
|
588
|
-
* @param target_dict The target dictionary to copy to.
|
|
589
|
-
* @param source_dict The source dictionary to copy from.
|
|
590
|
-
* @param key The key for the node value to copy.
|
|
591
|
-
* @param alt_source_key The alternative source key for lookup in *source_dict* or NULL.
|
|
592
|
-
*
|
|
593
|
-
* @result PLIST_ERR_SUCCESS on success or PLIST_ERR_INVALID_ARG if the source dictionary does not contain
|
|
594
|
-
* any entry with given key or alt_source_key.
|
|
595
|
-
*/
|
|
596
|
-
PLIST_API plist_err_t plist_dict_copy_int(plist_t target_dict, plist_t source_dict, const char *key, const char *alt_source_key);
|
|
597
|
-
|
|
598
|
-
/**
|
|
599
|
-
* Copy an unsigned integer value from *source_dict* to *target_dict*.
|
|
600
|
-
* The node is looked up in *source_dict* with given *key*, unless *alt_source_key*
|
|
601
|
-
* is non-NULL, in which case it is looked up with *alt_source_key*.
|
|
602
|
-
* The entry in *target_dict* is **always** created with *key*.
|
|
603
|
-
*
|
|
604
|
-
* @note The unsigned integer value from *source_dict* is retrieved with #plist_dict_get_uint,
|
|
605
|
-
* but is **always** created as #PLIST_INT.
|
|
606
|
-
*
|
|
607
|
-
* @param target_dict The target dictionary to copy to.
|
|
608
|
-
* @param source_dict The source dictionary to copy from.
|
|
609
|
-
* @param key The key for the node value to copy.
|
|
610
|
-
* @param alt_source_key The alternative source key for lookup in *source_dict* or NULL.
|
|
611
|
-
*
|
|
612
|
-
* @result PLIST_ERR_SUCCESS on success or PLIST_ERR_INVALID_ARG if the source dictionary does not contain
|
|
613
|
-
* any entry with given key or alt_source_key.
|
|
614
|
-
*/
|
|
615
|
-
PLIST_API plist_err_t plist_dict_copy_uint(plist_t target_dict, plist_t source_dict, const char *key, const char *alt_source_key);
|
|
616
|
-
|
|
617
|
-
/**
|
|
618
|
-
* Copy a #PLIST_DATA node from *source_dict* to *target_dict*.
|
|
619
|
-
* The node is looked up in *source_dict* with given *key*, unless *alt_source_key*
|
|
620
|
-
* is non-NULL, in which case it is looked up with *alt_source_key*.
|
|
621
|
-
* The entry in *target_dict* is **always** created with *key*.
|
|
622
|
-
*
|
|
623
|
-
* @note This function is like #plist_dict_copy_item, except that it fails
|
|
624
|
-
* if the source node is not of type #PLIST_DATA.
|
|
625
|
-
*
|
|
626
|
-
* @param target_dict The target dictionary to copy to.
|
|
627
|
-
* @param source_dict The source dictionary to copy from.
|
|
628
|
-
* @param key The key for the node value to copy.
|
|
629
|
-
* @param alt_source_key The alternative source key for lookup in *source_dict* or NULL.
|
|
630
|
-
*
|
|
631
|
-
* @result PLIST_ERR_SUCCESS on success or PLIST_ERR_INVALID_ARG if the source dictionary does not contain
|
|
632
|
-
* any entry with given key or alt_source_key, or if it is not of type #PLIST_DATA.
|
|
633
|
-
*/
|
|
634
|
-
PLIST_API plist_err_t plist_dict_copy_data(plist_t target_dict, plist_t source_dict, const char *key, const char *alt_source_key);
|
|
635
|
-
|
|
636
|
-
/**
|
|
637
|
-
* Copy a #PLIST_STRING node from *source_dict* to *target_dict*.
|
|
638
|
-
* The node is looked up in *source_dict* with given *key*, unless *alt_source_key*
|
|
639
|
-
* is non-NULL, in which case it is looked up with *alt_source_key*.
|
|
640
|
-
* The entry in *target_dict* is **always** created with *key*.
|
|
641
|
-
*
|
|
642
|
-
* @note This function is like #plist_dict_copy_item, except that it fails
|
|
643
|
-
* if the source node is not of type #PLIST_STRING.
|
|
644
|
-
*
|
|
645
|
-
* @param target_dict The target dictionary to copy to.
|
|
646
|
-
* @param source_dict The source dictionary to copy from.
|
|
647
|
-
* @param key The key for the node value to copy.
|
|
648
|
-
* @param alt_source_key The alternative source key for lookup in *source_dict* or NULL.
|
|
649
|
-
*
|
|
650
|
-
* @result PLIST_ERR_SUCCESS on success or PLIST_ERR_INVALID_ARG if the source dictionary does not contain
|
|
651
|
-
* any entry with given key or alt_source_key, or if it is not of type #PLIST_STRING.
|
|
652
|
-
*/
|
|
653
|
-
PLIST_API plist_err_t plist_dict_copy_string(plist_t target_dict, plist_t source_dict, const char *key, const char *alt_source_key);
|
|
654
|
-
|
|
655
|
-
/********************************************
|
|
656
|
-
* *
|
|
657
|
-
* Getters *
|
|
658
|
-
* *
|
|
659
|
-
********************************************/
|
|
660
|
-
|
|
661
|
-
/**
|
|
662
|
-
* Get the parent of a node
|
|
663
|
-
*
|
|
664
|
-
* @param node the parent (NULL if node is root)
|
|
665
|
-
*/
|
|
666
|
-
PLIST_API plist_t plist_get_parent(plist_t node);
|
|
667
|
-
|
|
668
|
-
/**
|
|
669
|
-
* Get the #plist_type of a node.
|
|
670
|
-
*
|
|
671
|
-
* @param node the node
|
|
672
|
-
* @return the type of the node
|
|
673
|
-
*/
|
|
674
|
-
PLIST_API plist_type plist_get_node_type(plist_t node);
|
|
675
|
-
|
|
676
|
-
/**
|
|
677
|
-
* Get the value of a #PLIST_KEY node.
|
|
678
|
-
* This function does nothing if node is not of type #PLIST_KEY
|
|
679
|
-
*
|
|
680
|
-
* @param node the node
|
|
681
|
-
* @param val a pointer to a C-string. This function allocates the memory,
|
|
682
|
-
* caller is responsible for freeing it.
|
|
683
|
-
* @note Use plist_mem_free() to free the allocated memory.
|
|
684
|
-
*/
|
|
685
|
-
PLIST_API void plist_get_key_val(plist_t node, char **val);
|
|
686
|
-
|
|
687
|
-
/**
|
|
688
|
-
* Get the value of a #PLIST_STRING node.
|
|
689
|
-
* This function does nothing if node is not of type #PLIST_STRING
|
|
690
|
-
*
|
|
691
|
-
* @param node the node
|
|
692
|
-
* @param val a pointer to a C-string. This function allocates the memory,
|
|
693
|
-
* caller is responsible for freeing it. Data is UTF-8 encoded.
|
|
694
|
-
* @note Use plist_mem_free() to free the allocated memory.
|
|
695
|
-
*/
|
|
696
|
-
PLIST_API void plist_get_string_val(plist_t node, char **val);
|
|
697
|
-
|
|
698
|
-
/**
|
|
699
|
-
* Get a pointer to the buffer of a #PLIST_STRING node.
|
|
700
|
-
*
|
|
701
|
-
* @note DO NOT MODIFY the buffer. Mind that the buffer is only available
|
|
702
|
-
* until the plist node gets freed. Make a copy if needed.
|
|
703
|
-
*
|
|
704
|
-
* @param node The node
|
|
705
|
-
* @param length If non-NULL, will be set to the length of the string
|
|
706
|
-
*
|
|
707
|
-
* @return Pointer to the NULL-terminated buffer.
|
|
708
|
-
*/
|
|
709
|
-
PLIST_API const char* plist_get_string_ptr(plist_t node, uint64_t* length);
|
|
710
|
-
|
|
711
|
-
/**
|
|
712
|
-
* Get the value of a #PLIST_BOOLEAN node.
|
|
713
|
-
* This function does nothing if node is not of type #PLIST_BOOLEAN
|
|
714
|
-
*
|
|
715
|
-
* @param node the node
|
|
716
|
-
* @param val a pointer to a uint8_t variable.
|
|
717
|
-
*/
|
|
718
|
-
PLIST_API void plist_get_bool_val(plist_t node, uint8_t * val);
|
|
719
|
-
|
|
720
|
-
/**
|
|
721
|
-
* Get the unsigned integer value of a #PLIST_INT node.
|
|
722
|
-
* This function does nothing if node is not of type #PLIST_INT
|
|
723
|
-
*
|
|
724
|
-
* @param node the node
|
|
725
|
-
* @param val a pointer to a uint64_t variable.
|
|
726
|
-
*/
|
|
727
|
-
PLIST_API void plist_get_uint_val(plist_t node, uint64_t * val);
|
|
728
|
-
|
|
729
|
-
/**
|
|
730
|
-
* Get the signed integer value of a #PLIST_INT node.
|
|
731
|
-
* This function does nothing if node is not of type #PLIST_INT
|
|
732
|
-
*
|
|
733
|
-
* @param node the node
|
|
734
|
-
* @param val a pointer to a int64_t variable.
|
|
735
|
-
*/
|
|
736
|
-
PLIST_API void plist_get_int_val(plist_t node, int64_t * val);
|
|
737
|
-
|
|
738
|
-
/**
|
|
739
|
-
* Get the value of a #PLIST_REAL node.
|
|
740
|
-
* This function does nothing if node is not of type #PLIST_REAL
|
|
741
|
-
*
|
|
742
|
-
* @param node the node
|
|
743
|
-
* @param val a pointer to a double variable.
|
|
744
|
-
*/
|
|
745
|
-
PLIST_API void plist_get_real_val(plist_t node, double *val);
|
|
746
|
-
|
|
747
|
-
/**
|
|
748
|
-
* Get the value of a #PLIST_DATA node.
|
|
749
|
-
* This function does nothing if node is not of type #PLIST_DATA
|
|
750
|
-
*
|
|
751
|
-
* @param node the node
|
|
752
|
-
* @param val a pointer to an unallocated char buffer. This function allocates the memory,
|
|
753
|
-
* caller is responsible for freeing it.
|
|
754
|
-
* @param length the length of the buffer
|
|
755
|
-
* @note Use plist_mem_free() to free the allocated memory.
|
|
756
|
-
*/
|
|
757
|
-
PLIST_API void plist_get_data_val(plist_t node, char **val, uint64_t * length);
|
|
758
|
-
|
|
759
|
-
/**
|
|
760
|
-
* Get a pointer to the data buffer of a #PLIST_DATA node.
|
|
761
|
-
*
|
|
762
|
-
* @note DO NOT MODIFY the buffer. Mind that the buffer is only available
|
|
763
|
-
* until the plist node gets freed. Make a copy if needed.
|
|
764
|
-
*
|
|
765
|
-
* @param node The node
|
|
766
|
-
* @param length Pointer to a uint64_t that will be set to the length of the buffer
|
|
767
|
-
*
|
|
768
|
-
* @return Pointer to the buffer
|
|
769
|
-
*/
|
|
770
|
-
PLIST_API const char* plist_get_data_ptr(plist_t node, uint64_t* length);
|
|
771
|
-
|
|
772
|
-
/**
|
|
773
|
-
* Get the value of a #PLIST_DATE node.
|
|
774
|
-
* This function does nothing if node is not of type #PLIST_DATE
|
|
775
|
-
*
|
|
776
|
-
* @param node the node
|
|
777
|
-
* @param sec a pointer to an int64_t variable. Represents the number of seconds since 01/01/1970 (UNIX timestamp).
|
|
778
|
-
*/
|
|
779
|
-
PLIST_API void plist_get_unix_date_val(plist_t node, int64_t *sec);
|
|
780
|
-
|
|
781
|
-
/**
|
|
782
|
-
* Get the value of a #PLIST_UID node.
|
|
783
|
-
* This function does nothing if node is not of type #PLIST_UID
|
|
784
|
-
*
|
|
785
|
-
* @param node the node
|
|
786
|
-
* @param val a pointer to a uint64_t variable.
|
|
787
|
-
*/
|
|
788
|
-
PLIST_API void plist_get_uid_val(plist_t node, uint64_t * val);
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
/********************************************
|
|
792
|
-
* *
|
|
793
|
-
* Setters *
|
|
794
|
-
* *
|
|
795
|
-
********************************************/
|
|
796
|
-
|
|
797
|
-
/**
|
|
798
|
-
* Set the value of a node.
|
|
799
|
-
* Forces type of node to #PLIST_KEY
|
|
800
|
-
*
|
|
801
|
-
* @param node the node
|
|
802
|
-
* @param val the key value
|
|
803
|
-
*/
|
|
804
|
-
PLIST_API void plist_set_key_val(plist_t node, const char *val);
|
|
805
|
-
|
|
806
|
-
/**
|
|
807
|
-
* Set the value of a node.
|
|
808
|
-
* Forces type of node to #PLIST_STRING
|
|
809
|
-
*
|
|
810
|
-
* @param node the node
|
|
811
|
-
* @param val the string value. The string is copied when set and will be
|
|
812
|
-
* freed by the node.
|
|
813
|
-
*/
|
|
814
|
-
PLIST_API void plist_set_string_val(plist_t node, const char *val);
|
|
815
|
-
|
|
816
|
-
/**
|
|
817
|
-
* Set the value of a node.
|
|
818
|
-
* Forces type of node to #PLIST_BOOLEAN
|
|
819
|
-
*
|
|
820
|
-
* @param node the node
|
|
821
|
-
* @param val the boolean value
|
|
822
|
-
*/
|
|
823
|
-
PLIST_API void plist_set_bool_val(plist_t node, uint8_t val);
|
|
824
|
-
|
|
825
|
-
/**
|
|
826
|
-
* Set the value of a node.
|
|
827
|
-
* Forces type of node to #PLIST_INT
|
|
828
|
-
*
|
|
829
|
-
* @param node the node
|
|
830
|
-
* @param val the unsigned integer value
|
|
831
|
-
*/
|
|
832
|
-
PLIST_API void plist_set_uint_val(plist_t node, uint64_t val);
|
|
833
|
-
|
|
834
|
-
/**
|
|
835
|
-
* Set the value of a node.
|
|
836
|
-
* Forces type of node to #PLIST_INT
|
|
837
|
-
*
|
|
838
|
-
* @param node the node
|
|
839
|
-
* @param val the signed integer value
|
|
840
|
-
*/
|
|
841
|
-
PLIST_API void plist_set_int_val(plist_t node, int64_t val);
|
|
842
|
-
|
|
843
|
-
/**
|
|
844
|
-
* Set the value of a node.
|
|
845
|
-
* Forces type of node to #PLIST_REAL
|
|
846
|
-
*
|
|
847
|
-
* @param node the node
|
|
848
|
-
* @param val the real value
|
|
849
|
-
*/
|
|
850
|
-
PLIST_API void plist_set_real_val(plist_t node, double val);
|
|
851
|
-
|
|
852
|
-
/**
|
|
853
|
-
* Set the value of a node.
|
|
854
|
-
* Forces type of node to #PLIST_DATA
|
|
855
|
-
*
|
|
856
|
-
* @param node the node
|
|
857
|
-
* @param val the binary buffer. The buffer is copied when set and will
|
|
858
|
-
* be freed by the node.
|
|
859
|
-
* @param length the length of the buffer
|
|
860
|
-
*/
|
|
861
|
-
PLIST_API void plist_set_data_val(plist_t node, const char *val, uint64_t length);
|
|
862
|
-
|
|
863
|
-
/**
|
|
864
|
-
* Set the value of a node.
|
|
865
|
-
* Forces type of node to #PLIST_DATE
|
|
866
|
-
*
|
|
867
|
-
* @param node the node
|
|
868
|
-
* @param sec the number of seconds since 01/01/1970 (UNIX timestamp)
|
|
869
|
-
*/
|
|
870
|
-
PLIST_API void plist_set_unix_date_val(plist_t node, int64_t sec);
|
|
871
|
-
|
|
872
|
-
/**
|
|
873
|
-
* Set the value of a node.
|
|
874
|
-
* Forces type of node to #PLIST_UID
|
|
875
|
-
*
|
|
876
|
-
* @param node the node
|
|
877
|
-
* @param val the unsigned integer value
|
|
878
|
-
*/
|
|
879
|
-
PLIST_API void plist_set_uid_val(plist_t node, uint64_t val);
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
/********************************************
|
|
883
|
-
* *
|
|
884
|
-
* Import & Export *
|
|
885
|
-
* *
|
|
886
|
-
********************************************/
|
|
887
|
-
|
|
888
|
-
/**
|
|
889
|
-
* Export the #plist_t structure to XML format.
|
|
890
|
-
*
|
|
891
|
-
* @param plist the root node to export
|
|
892
|
-
* @param plist_xml a pointer to a C-string. This function allocates the memory,
|
|
893
|
-
* caller is responsible for freeing it. Data is UTF-8 encoded.
|
|
894
|
-
* @param length a pointer to an uint32_t variable. Represents the length of the allocated buffer.
|
|
895
|
-
* @return PLIST_ERR_SUCCESS on success or a #plist_err_t on failure
|
|
896
|
-
* @note Use plist_mem_free() to free the allocated memory.
|
|
897
|
-
*/
|
|
898
|
-
PLIST_API plist_err_t plist_to_xml(plist_t plist, char **plist_xml, uint32_t * length);
|
|
899
|
-
|
|
900
|
-
/**
|
|
901
|
-
* Export the #plist_t structure to binary format.
|
|
902
|
-
*
|
|
903
|
-
* @param plist the root node to export
|
|
904
|
-
* @param plist_bin a pointer to a char* buffer. This function allocates the memory,
|
|
905
|
-
* caller is responsible for freeing it.
|
|
906
|
-
* @param length a pointer to an uint32_t variable. Represents the length of the allocated buffer.
|
|
907
|
-
* @return PLIST_ERR_SUCCESS on success or a #plist_err_t on failure
|
|
908
|
-
* @note Use plist_mem_free() to free the allocated memory.
|
|
909
|
-
*/
|
|
910
|
-
PLIST_API plist_err_t plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length);
|
|
911
|
-
|
|
912
|
-
/**
|
|
913
|
-
* Export the #plist_t structure to JSON format.
|
|
914
|
-
*
|
|
915
|
-
* @param plist the root node to export
|
|
916
|
-
* @param plist_json a pointer to a char* buffer. This function allocates the memory,
|
|
917
|
-
* caller is responsible for freeing it.
|
|
918
|
-
* @param length a pointer to an uint32_t variable. Represents the length of the allocated buffer.
|
|
919
|
-
* @param prettify pretty print the output if != 0
|
|
920
|
-
* @return PLIST_ERR_SUCCESS on success or a #plist_err_t on failure
|
|
921
|
-
* @note Use plist_mem_free() to free the allocated memory.
|
|
922
|
-
*/
|
|
923
|
-
PLIST_API plist_err_t plist_to_json(plist_t plist, char **plist_json, uint32_t* length, int prettify);
|
|
924
|
-
|
|
925
|
-
/**
|
|
926
|
-
* Export the #plist_t structure to OpenStep format.
|
|
927
|
-
*
|
|
928
|
-
* @param plist the root node to export
|
|
929
|
-
* @param plist_openstep a pointer to a char* buffer. This function allocates the memory,
|
|
930
|
-
* caller is responsible for freeing it.
|
|
931
|
-
* @param length a pointer to an uint32_t variable. Represents the length of the allocated buffer.
|
|
932
|
-
* @param prettify pretty print the output if != 0
|
|
933
|
-
* @return PLIST_ERR_SUCCESS on success or a #plist_err_t on failure
|
|
934
|
-
* @note Use plist_mem_free() to free the allocated memory.
|
|
935
|
-
*/
|
|
936
|
-
PLIST_API plist_err_t plist_to_openstep(plist_t plist, char **plist_openstep, uint32_t* length, int prettify);
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
/**
|
|
940
|
-
* Import the #plist_t structure from XML format.
|
|
941
|
-
*
|
|
942
|
-
* @param plist_xml a pointer to the xml buffer.
|
|
943
|
-
* @param length length of the buffer to read.
|
|
944
|
-
* @param plist a pointer to the imported plist.
|
|
945
|
-
* @return PLIST_ERR_SUCCESS on success or a #plist_err_t on failure
|
|
946
|
-
*/
|
|
947
|
-
PLIST_API plist_err_t plist_from_xml(const char *plist_xml, uint32_t length, plist_t * plist);
|
|
948
|
-
|
|
949
|
-
/**
|
|
950
|
-
* Import the #plist_t structure from binary format.
|
|
951
|
-
*
|
|
952
|
-
* @param plist_bin a pointer to the xml buffer.
|
|
953
|
-
* @param length length of the buffer to read.
|
|
954
|
-
* @param plist a pointer to the imported plist.
|
|
955
|
-
* @return PLIST_ERR_SUCCESS on success or a #plist_err_t on failure
|
|
956
|
-
*/
|
|
957
|
-
PLIST_API plist_err_t plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist);
|
|
958
|
-
|
|
959
|
-
/**
|
|
960
|
-
* Import the #plist_t structure from JSON format.
|
|
961
|
-
*
|
|
962
|
-
* @param json a pointer to the JSON buffer.
|
|
963
|
-
* @param length length of the buffer to read.
|
|
964
|
-
* @param plist a pointer to the imported plist.
|
|
965
|
-
* @return PLIST_ERR_SUCCESS on success or a #plist_err_t on failure
|
|
966
|
-
*/
|
|
967
|
-
PLIST_API plist_err_t plist_from_json(const char *json, uint32_t length, plist_t * plist);
|
|
968
|
-
|
|
969
|
-
/**
|
|
970
|
-
* Import the #plist_t structure from OpenStep plist format.
|
|
971
|
-
*
|
|
972
|
-
* @param openstep a pointer to the OpenStep plist buffer.
|
|
973
|
-
* @param length length of the buffer to read.
|
|
974
|
-
* @param plist a pointer to the imported plist.
|
|
975
|
-
* @return PLIST_ERR_SUCCESS on success or a #plist_err_t on failure
|
|
976
|
-
*/
|
|
977
|
-
PLIST_API plist_err_t plist_from_openstep(const char *openstep, uint32_t length, plist_t * plist);
|
|
978
|
-
|
|
979
|
-
/**
|
|
980
|
-
* Import the #plist_t structure from memory data.
|
|
981
|
-
*
|
|
982
|
-
* This function will look at the first bytes of plist_data
|
|
983
|
-
* to determine if plist_data contains a binary, JSON, OpenStep, or XML plist
|
|
984
|
-
* and tries to parse the data in the appropriate format.
|
|
985
|
-
* @note This is just a convenience function and the format detection is
|
|
986
|
-
* very basic. It checks with plist_is_binary() if the data supposedly
|
|
987
|
-
* contains binary plist data, if not it checks if the first bytes have
|
|
988
|
-
* either '{' or '[' and assumes JSON format, and XML tags will result
|
|
989
|
-
* in parsing as XML, otherwise it will try to parse as OpenStep.
|
|
990
|
-
*
|
|
991
|
-
* @param plist_data A pointer to the memory buffer containing plist data.
|
|
992
|
-
* @param length Length of the buffer to read.
|
|
993
|
-
* @param plist A pointer to the imported plist.
|
|
994
|
-
* @param format If non-NULL, the #plist_format_t value pointed to will be set to the parsed format.
|
|
995
|
-
* @return PLIST_ERR_SUCCESS on success or a #plist_err_t on failure
|
|
996
|
-
*/
|
|
997
|
-
PLIST_API plist_err_t plist_from_memory(const char *plist_data, uint32_t length, plist_t *plist, plist_format_t *format);
|
|
998
|
-
|
|
999
|
-
/**
|
|
1000
|
-
* Import the #plist_t structure directly from file.
|
|
1001
|
-
*
|
|
1002
|
-
* This function will look at the first bytes of the file data
|
|
1003
|
-
* to determine if it contains a binary, JSON, OpenStep, or XML plist
|
|
1004
|
-
* and tries to parse the data in the appropriate format.
|
|
1005
|
-
* Uses plist_from_memory() internally.
|
|
1006
|
-
*
|
|
1007
|
-
* @param filename The name of the file to parse.
|
|
1008
|
-
* @param plist A pointer to the imported plist.
|
|
1009
|
-
* @param format If non-NULL, the #plist_format_t value pointed to will be set to the parsed format.
|
|
1010
|
-
* @return PLIST_ERR_SUCCESS on success or a #plist_err_t on failure
|
|
1011
|
-
*/
|
|
1012
|
-
PLIST_API plist_err_t plist_read_from_file(const char *filename, plist_t *plist, plist_format_t *format);
|
|
1013
|
-
|
|
1014
|
-
/**
|
|
1015
|
-
* Write the #plist_t structure to a NULL-terminated string using the given format and options.
|
|
1016
|
-
*
|
|
1017
|
-
* @param plist The input plist structure
|
|
1018
|
-
* @param output Pointer to a char* buffer. This function allocates the memory,
|
|
1019
|
-
* caller is responsible for freeing it.
|
|
1020
|
-
* @param length A pointer to a uint32_t value that will receive the lenght of the allocated buffer.
|
|
1021
|
-
* @param format A #plist_format_t value that specifies the output format to use.
|
|
1022
|
-
* @param options One or more bitwise ORed values of #plist_write_options_t.
|
|
1023
|
-
* @return PLIST_ERR_SUCCESS on success or a #plist_err_t on failure.
|
|
1024
|
-
* @note Use plist_mem_free() to free the allocated memory.
|
|
1025
|
-
* @note #PLIST_FORMAT_BINARY is not supported by this function.
|
|
1026
|
-
*/
|
|
1027
|
-
PLIST_API plist_err_t plist_write_to_string(plist_t plist, char **output, uint32_t* length, plist_format_t format, plist_write_options_t options);
|
|
1028
|
-
|
|
1029
|
-
/**
|
|
1030
|
-
* Write the #plist_t structure to a FILE* stream using the given format and options.
|
|
1031
|
-
*
|
|
1032
|
-
* @param plist The input plist structure
|
|
1033
|
-
* @param stream A writeable FILE* stream that the data will be written to.
|
|
1034
|
-
* @param format A #plist_format_t value that specifies the output format to use.
|
|
1035
|
-
* @param options One or more bitwise ORed values of #plist_write_options_t.
|
|
1036
|
-
* @return PLIST_ERR_SUCCESS on success or a #plist_err_t on failure.
|
|
1037
|
-
* @note While this function allows all formats to be written to the given stream,
|
|
1038
|
-
* only the formats #PLIST_FORMAT_PRINT, #PLIST_FORMAT_LIMD, and #PLIST_FORMAT_PLUTIL
|
|
1039
|
-
* (basically all output-only formats) are directly and efficiently written to the stream;
|
|
1040
|
-
* the other formats are written to a memory buffer first.
|
|
1041
|
-
*/
|
|
1042
|
-
PLIST_API plist_err_t plist_write_to_stream(plist_t plist, FILE* stream, plist_format_t format, plist_write_options_t options);
|
|
1043
|
-
|
|
1044
|
-
/**
|
|
1045
|
-
* Write the #plist_t structure to a file at given path using the given format and options.
|
|
1046
|
-
*
|
|
1047
|
-
* @param plist The input plist structure
|
|
1048
|
-
* @param filename The file name of the file to write to. Existing files will be overwritten.
|
|
1049
|
-
* @param format A #plist_format_t value that specifies the output format to use.
|
|
1050
|
-
* @param options One or more bitwise ORed values of #plist_write_options_t.
|
|
1051
|
-
* @return PLIST_ERR_SUCCESS on success or a #plist_err_t on failure.
|
|
1052
|
-
* @note Use plist_mem_free() to free the allocated memory.
|
|
1053
|
-
*/
|
|
1054
|
-
PLIST_API plist_err_t plist_write_to_file(plist_t plist, const char *filename, plist_format_t format, plist_write_options_t options);
|
|
1055
|
-
|
|
1056
|
-
/**
|
|
1057
|
-
* Print the given plist in human-readable format to standard output.
|
|
1058
|
-
* This is equivalent to
|
|
1059
|
-
* <code>plist_write_to_stream(plist, stdout, PLIST_FORMAT_PRINT, PLIST_OPT_PARTIAL_DATA);</code>
|
|
1060
|
-
* @param plist The #plist_t structure to print
|
|
1061
|
-
* @note For #PLIST_DATA nodes, only a maximum of 24 bytes (first 16 and last 8) are written.
|
|
1062
|
-
*/
|
|
1063
|
-
PLIST_API void plist_print(plist_t plist);
|
|
1064
|
-
|
|
1065
|
-
/**
|
|
1066
|
-
* Test if in-memory plist data is in binary format.
|
|
1067
|
-
* This function will look at the first bytes of plist_data to determine
|
|
1068
|
-
* if it supposedly contains a binary plist.
|
|
1069
|
-
* @note The function is not validating the whole memory buffer to check
|
|
1070
|
-
* if the content is truly a plist, it is only using some heuristic on
|
|
1071
|
-
* the first few bytes of plist_data.
|
|
1072
|
-
*
|
|
1073
|
-
* @param plist_data a pointer to the memory buffer containing plist data.
|
|
1074
|
-
* @param length length of the buffer to read.
|
|
1075
|
-
* @return 1 if the buffer is a binary plist, 0 otherwise.
|
|
1076
|
-
*/
|
|
1077
|
-
PLIST_API int plist_is_binary(const char *plist_data, uint32_t length);
|
|
1078
|
-
|
|
1079
|
-
/********************************************
|
|
1080
|
-
* *
|
|
1081
|
-
* Utils *
|
|
1082
|
-
* *
|
|
1083
|
-
********************************************/
|
|
1084
|
-
|
|
1085
|
-
/**
|
|
1086
|
-
* Get a node from its path. Each path element depends on the associated father node type.
|
|
1087
|
-
* For Dictionaries, var args are casted to const char*, for arrays, var args are caster to uint32_t
|
|
1088
|
-
* Search is breath first order.
|
|
1089
|
-
*
|
|
1090
|
-
* @param plist the node to access result from.
|
|
1091
|
-
* @param length length of the path to access
|
|
1092
|
-
* @return the value to access.
|
|
1093
|
-
*/
|
|
1094
|
-
PLIST_API plist_t plist_access_path(plist_t plist, uint32_t length, ...);
|
|
1095
|
-
|
|
1096
|
-
/**
|
|
1097
|
-
* Variadic version of #plist_access_path.
|
|
1098
|
-
*
|
|
1099
|
-
* @param plist the node to access result from.
|
|
1100
|
-
* @param length length of the path to access
|
|
1101
|
-
* @param v list of array's index and dic'st key
|
|
1102
|
-
* @return the value to access.
|
|
1103
|
-
*/
|
|
1104
|
-
PLIST_API plist_t plist_access_pathv(plist_t plist, uint32_t length, va_list v);
|
|
1105
|
-
|
|
1106
|
-
/**
|
|
1107
|
-
* Compare two node values
|
|
1108
|
-
*
|
|
1109
|
-
* @param node_l left node to compare
|
|
1110
|
-
* @param node_r rigth node to compare
|
|
1111
|
-
* @return TRUE is type and value match, FALSE otherwise.
|
|
1112
|
-
*/
|
|
1113
|
-
PLIST_API char plist_compare_node_value(plist_t node_l, plist_t node_r);
|
|
1114
|
-
|
|
1115
|
-
/** Helper macro used by PLIST_IS_* macros that will evaluate the type of a plist node. */
|
|
1116
|
-
#define _PLIST_IS_TYPE(__plist, __plist_type) (__plist && (plist_get_node_type(__plist) == PLIST_##__plist_type))
|
|
1117
|
-
|
|
1118
|
-
/* Helper macros for the different plist types */
|
|
1119
|
-
/** Evaluates to true if the given plist node is of type PLIST_BOOLEAN */
|
|
1120
|
-
#define PLIST_IS_BOOLEAN(__plist) _PLIST_IS_TYPE(__plist, BOOLEAN)
|
|
1121
|
-
/** Evaluates to true if the given plist node is of type PLIST_INT */
|
|
1122
|
-
#define PLIST_IS_INT(__plist) _PLIST_IS_TYPE(__plist, INT)
|
|
1123
|
-
/** Evaluates to true if the given plist node is of type PLIST_REAL */
|
|
1124
|
-
#define PLIST_IS_REAL(__plist) _PLIST_IS_TYPE(__plist, REAL)
|
|
1125
|
-
/** Evaluates to true if the given plist node is of type PLIST_STRING */
|
|
1126
|
-
#define PLIST_IS_STRING(__plist) _PLIST_IS_TYPE(__plist, STRING)
|
|
1127
|
-
/** Evaluates to true if the given plist node is of type PLIST_ARRAY */
|
|
1128
|
-
#define PLIST_IS_ARRAY(__plist) _PLIST_IS_TYPE(__plist, ARRAY)
|
|
1129
|
-
/** Evaluates to true if the given plist node is of type PLIST_DICT */
|
|
1130
|
-
#define PLIST_IS_DICT(__plist) _PLIST_IS_TYPE(__plist, DICT)
|
|
1131
|
-
/** Evaluates to true if the given plist node is of type PLIST_DATE */
|
|
1132
|
-
#define PLIST_IS_DATE(__plist) _PLIST_IS_TYPE(__plist, DATE)
|
|
1133
|
-
/** Evaluates to true if the given plist node is of type PLIST_DATA */
|
|
1134
|
-
#define PLIST_IS_DATA(__plist) _PLIST_IS_TYPE(__plist, DATA)
|
|
1135
|
-
/** Evaluates to true if the given plist node is of type PLIST_KEY */
|
|
1136
|
-
#define PLIST_IS_KEY(__plist) _PLIST_IS_TYPE(__plist, KEY)
|
|
1137
|
-
/** Evaluates to true if the given plist node is of type PLIST_UID */
|
|
1138
|
-
#define PLIST_IS_UID(__plist) _PLIST_IS_TYPE(__plist, UID)
|
|
1139
|
-
/* for backwards compatibility */
|
|
1140
|
-
#define PLIST_IS_UINT PLIST_IS_INT
|
|
1141
|
-
|
|
1142
|
-
/**
|
|
1143
|
-
* Helper function to check the value of a PLIST_BOOL node.
|
|
1144
|
-
*
|
|
1145
|
-
* @param boolnode node of type PLIST_BOOL
|
|
1146
|
-
* @return 1 if the boolean node has a value of TRUE or 0 if FALSE.
|
|
1147
|
-
*/
|
|
1148
|
-
PLIST_API int plist_bool_val_is_true(plist_t boolnode);
|
|
1149
|
-
|
|
1150
|
-
/**
|
|
1151
|
-
* Helper function to test if a given #PLIST_INT node's value is negative
|
|
1152
|
-
*
|
|
1153
|
-
* @param intnode node of type PLIST_INT
|
|
1154
|
-
* @return 1 if the node's value is negative, or 0 if positive.
|
|
1155
|
-
*/
|
|
1156
|
-
PLIST_API int plist_int_val_is_negative(plist_t intnode);
|
|
1157
|
-
|
|
1158
|
-
/**
|
|
1159
|
-
* Helper function to compare the value of a PLIST_INT node against
|
|
1160
|
-
* a given signed integer value.
|
|
1161
|
-
*
|
|
1162
|
-
* @param uintnode node of type PLIST_INT
|
|
1163
|
-
* @param cmpval value to compare against
|
|
1164
|
-
* @return 0 if the node's value and cmpval are equal,
|
|
1165
|
-
* 1 if the node's value is greater than cmpval,
|
|
1166
|
-
* or -1 if the node's value is less than cmpval.
|
|
1167
|
-
*/
|
|
1168
|
-
PLIST_API int plist_int_val_compare(plist_t uintnode, int64_t cmpval);
|
|
1169
|
-
|
|
1170
|
-
/**
|
|
1171
|
-
* Helper function to compare the value of a PLIST_INT node against
|
|
1172
|
-
* a given unsigned integer value.
|
|
1173
|
-
*
|
|
1174
|
-
* @param uintnode node of type PLIST_INT
|
|
1175
|
-
* @param cmpval value to compare against
|
|
1176
|
-
* @return 0 if the node's value and cmpval are equal,
|
|
1177
|
-
* 1 if the node's value is greater than cmpval,
|
|
1178
|
-
* or -1 if the node's value is less than cmpval.
|
|
1179
|
-
*/
|
|
1180
|
-
PLIST_API int plist_uint_val_compare(plist_t uintnode, uint64_t cmpval);
|
|
1181
|
-
|
|
1182
|
-
/**
|
|
1183
|
-
* Helper function to compare the value of a PLIST_UID node against
|
|
1184
|
-
* a given value.
|
|
1185
|
-
*
|
|
1186
|
-
* @param uidnode node of type PLIST_UID
|
|
1187
|
-
* @param cmpval value to compare against
|
|
1188
|
-
* @return 0 if the node's value and cmpval are equal,
|
|
1189
|
-
* 1 if the node's value is greater than cmpval,
|
|
1190
|
-
* or -1 if the node's value is less than cmpval.
|
|
1191
|
-
*/
|
|
1192
|
-
PLIST_API int plist_uid_val_compare(plist_t uidnode, uint64_t cmpval);
|
|
1193
|
-
|
|
1194
|
-
/**
|
|
1195
|
-
* Helper function to compare the value of a PLIST_REAL node against
|
|
1196
|
-
* a given value.
|
|
1197
|
-
*
|
|
1198
|
-
* @note WARNING: Comparing floating point values can give inaccurate
|
|
1199
|
-
* results because of the nature of floating point values on computer
|
|
1200
|
-
* systems. While this function is designed to be as accurate as
|
|
1201
|
-
* possible, please don't rely on it too much.
|
|
1202
|
-
*
|
|
1203
|
-
* @param realnode node of type PLIST_REAL
|
|
1204
|
-
* @param cmpval value to compare against
|
|
1205
|
-
* @return 0 if the node's value and cmpval are (almost) equal,
|
|
1206
|
-
* 1 if the node's value is greater than cmpval,
|
|
1207
|
-
* or -1 if the node's value is less than cmpval.
|
|
1208
|
-
*/
|
|
1209
|
-
PLIST_API int plist_real_val_compare(plist_t realnode, double cmpval);
|
|
1210
|
-
|
|
1211
|
-
/**
|
|
1212
|
-
* Helper function to compare the value of a PLIST_DATE node against
|
|
1213
|
-
* a given number of seconds since epoch (UNIX timestamp).
|
|
1214
|
-
*
|
|
1215
|
-
* @param datenode node of type PLIST_DATE
|
|
1216
|
-
* @param cmpval Number of seconds to compare against (UNIX timestamp)
|
|
1217
|
-
* @return 0 if the node's date is equal to the supplied values,
|
|
1218
|
-
* 1 if the node's date is greater than the supplied values,
|
|
1219
|
-
* or -1 if the node's date is less than the supplied values.
|
|
1220
|
-
*/
|
|
1221
|
-
PLIST_API int plist_unix_date_val_compare(plist_t datenode, int64_t cmpval);
|
|
1222
|
-
|
|
1223
|
-
/**
|
|
1224
|
-
* Helper function to compare the value of a PLIST_STRING node against
|
|
1225
|
-
* a given value.
|
|
1226
|
-
* This function basically behaves like strcmp.
|
|
1227
|
-
*
|
|
1228
|
-
* @param strnode node of type PLIST_STRING
|
|
1229
|
-
* @param cmpval value to compare against
|
|
1230
|
-
* @return 0 if the node's value and cmpval are equal,
|
|
1231
|
-
* > 0 if the node's value is lexicographically greater than cmpval,
|
|
1232
|
-
* or < 0 if the node's value is lexicographically less than cmpval.
|
|
1233
|
-
*/
|
|
1234
|
-
PLIST_API int plist_string_val_compare(plist_t strnode, const char* cmpval);
|
|
1235
|
-
|
|
1236
|
-
/**
|
|
1237
|
-
* Helper function to compare the value of a PLIST_STRING node against
|
|
1238
|
-
* a given value, while not comparing more than n characters.
|
|
1239
|
-
* This function basically behaves like strncmp.
|
|
1240
|
-
*
|
|
1241
|
-
* @param strnode node of type PLIST_STRING
|
|
1242
|
-
* @param cmpval value to compare against
|
|
1243
|
-
* @param n maximum number of characters to compare
|
|
1244
|
-
* @return 0 if the node's value and cmpval are equal,
|
|
1245
|
-
* > 0 if the node's value is lexicographically greater than cmpval,
|
|
1246
|
-
* or < 0 if the node's value is lexicographically less than cmpval.
|
|
1247
|
-
*/
|
|
1248
|
-
PLIST_API int plist_string_val_compare_with_size(plist_t strnode, const char* cmpval, size_t n);
|
|
1249
|
-
|
|
1250
|
-
/**
|
|
1251
|
-
* Helper function to match a given substring in the value of a
|
|
1252
|
-
* PLIST_STRING node.
|
|
1253
|
-
*
|
|
1254
|
-
* @param strnode node of type PLIST_STRING
|
|
1255
|
-
* @param substr value to match
|
|
1256
|
-
* @return 1 if the node's value contains the given substring,
|
|
1257
|
-
* or 0 if not.
|
|
1258
|
-
*/
|
|
1259
|
-
PLIST_API int plist_string_val_contains(plist_t strnode, const char* substr);
|
|
1260
|
-
|
|
1261
|
-
/**
|
|
1262
|
-
* Helper function to compare the value of a PLIST_KEY node against
|
|
1263
|
-
* a given value.
|
|
1264
|
-
* This function basically behaves like strcmp.
|
|
1265
|
-
*
|
|
1266
|
-
* @param keynode node of type PLIST_KEY
|
|
1267
|
-
* @param cmpval value to compare against
|
|
1268
|
-
* @return 0 if the node's value and cmpval are equal,
|
|
1269
|
-
* > 0 if the node's value is lexicographically greater than cmpval,
|
|
1270
|
-
* or < 0 if the node's value is lexicographically less than cmpval.
|
|
1271
|
-
*/
|
|
1272
|
-
PLIST_API int plist_key_val_compare(plist_t keynode, const char* cmpval);
|
|
1273
|
-
|
|
1274
|
-
/**
|
|
1275
|
-
* Helper function to compare the value of a PLIST_KEY node against
|
|
1276
|
-
* a given value, while not comparing more than n characters.
|
|
1277
|
-
* This function basically behaves like strncmp.
|
|
1278
|
-
*
|
|
1279
|
-
* @param keynode node of type PLIST_KEY
|
|
1280
|
-
* @param cmpval value to compare against
|
|
1281
|
-
* @param n maximum number of characters to compare
|
|
1282
|
-
* @return 0 if the node's value and cmpval are equal,
|
|
1283
|
-
* > 0 if the node's value is lexicographically greater than cmpval,
|
|
1284
|
-
* or < 0 if the node's value is lexicographically less than cmpval.
|
|
1285
|
-
*/
|
|
1286
|
-
PLIST_API int plist_key_val_compare_with_size(plist_t keynode, const char* cmpval, size_t n);
|
|
1287
|
-
|
|
1288
|
-
/**
|
|
1289
|
-
* Helper function to match a given substring in the value of a
|
|
1290
|
-
* PLIST_KEY node.
|
|
1291
|
-
*
|
|
1292
|
-
* @param keynode node of type PLIST_KEY
|
|
1293
|
-
* @param substr value to match
|
|
1294
|
-
* @return 1 if the node's value contains the given substring,
|
|
1295
|
-
* or 0 if not.
|
|
1296
|
-
*/
|
|
1297
|
-
PLIST_API int plist_key_val_contains(plist_t keynode, const char* substr);
|
|
1298
|
-
|
|
1299
|
-
/**
|
|
1300
|
-
* Helper function to compare the data of a PLIST_DATA node against
|
|
1301
|
-
* a given blob and size.
|
|
1302
|
-
* This function basically behaves like memcmp after making sure the
|
|
1303
|
-
* size of the node's data value is equal to the size of cmpval (n),
|
|
1304
|
-
* making this a "full match" comparison.
|
|
1305
|
-
*
|
|
1306
|
-
* @param datanode node of type PLIST_DATA
|
|
1307
|
-
* @param cmpval data blob to compare against
|
|
1308
|
-
* @param n size of data blob passed in cmpval
|
|
1309
|
-
* @return 0 if the node's data blob and cmpval are equal,
|
|
1310
|
-
* > 0 if the node's value is lexicographically greater than cmpval,
|
|
1311
|
-
* or < 0 if the node's value is lexicographically less than cmpval.
|
|
1312
|
-
*/
|
|
1313
|
-
PLIST_API int plist_data_val_compare(plist_t datanode, const uint8_t* cmpval, size_t n);
|
|
1314
|
-
|
|
1315
|
-
/**
|
|
1316
|
-
* Helper function to compare the data of a PLIST_DATA node against
|
|
1317
|
-
* a given blob and size, while no more than n bytes are compared.
|
|
1318
|
-
* This function basically behaves like memcmp after making sure the
|
|
1319
|
-
* size of the node's data value is at least n, making this a
|
|
1320
|
-
* "starts with" comparison.
|
|
1321
|
-
*
|
|
1322
|
-
* @param datanode node of type PLIST_DATA
|
|
1323
|
-
* @param cmpval data blob to compare against
|
|
1324
|
-
* @param n size of data blob passed in cmpval
|
|
1325
|
-
* @return 0 if the node's value and cmpval are equal,
|
|
1326
|
-
* > 0 if the node's value is lexicographically greater than cmpval,
|
|
1327
|
-
* or < 0 if the node's value is lexicographically less than cmpval.
|
|
1328
|
-
*/
|
|
1329
|
-
PLIST_API int plist_data_val_compare_with_size(plist_t datanode, const uint8_t* cmpval, size_t n);
|
|
1330
|
-
|
|
1331
|
-
/**
|
|
1332
|
-
* Helper function to match a given data blob within the value of a
|
|
1333
|
-
* PLIST_DATA node.
|
|
1334
|
-
*
|
|
1335
|
-
* @param datanode node of type PLIST_KEY
|
|
1336
|
-
* @param cmpval data blob to match
|
|
1337
|
-
* @param n size of data blob passed in cmpval
|
|
1338
|
-
* @return 1 if the node's value contains the given data blob
|
|
1339
|
-
* or 0 if not.
|
|
1340
|
-
*/
|
|
1341
|
-
PLIST_API int plist_data_val_contains(plist_t datanode, const uint8_t* cmpval, size_t n);
|
|
1342
|
-
|
|
1343
|
-
/**
|
|
1344
|
-
* Sort all PLIST_DICT key/value pairs in a property list lexicographically
|
|
1345
|
-
* by key. Recurses into the child nodes if necessary.
|
|
1346
|
-
*
|
|
1347
|
-
* @param plist The property list to perform the sorting operation on.
|
|
1348
|
-
*/
|
|
1349
|
-
PLIST_API void plist_sort(plist_t plist);
|
|
1350
|
-
|
|
1351
|
-
/**
|
|
1352
|
-
* Free memory allocated by relevant libplist API calls:
|
|
1353
|
-
* - plist_to_xml()
|
|
1354
|
-
* - plist_to_bin()
|
|
1355
|
-
* - plist_get_key_val()
|
|
1356
|
-
* - plist_get_string_val()
|
|
1357
|
-
* - plist_get_data_val()
|
|
1358
|
-
*
|
|
1359
|
-
* @param ptr pointer to the memory to free
|
|
1360
|
-
*
|
|
1361
|
-
* @note Do not use this function to free plist_t nodes, use plist_free()
|
|
1362
|
-
* instead.
|
|
1363
|
-
*/
|
|
1364
|
-
PLIST_API void plist_mem_free(void* ptr);
|
|
1365
|
-
|
|
1366
|
-
/**
|
|
1367
|
-
* Set debug level for the format parsers.
|
|
1368
|
-
* @note This function does nothing if libplist was not configured with --enable-debug .
|
|
1369
|
-
*
|
|
1370
|
-
* @param debug Debug level. Currently, only 0 (off) and 1 (enabled) are supported.
|
|
1371
|
-
*/
|
|
1372
|
-
PLIST_API void plist_set_debug(int debug);
|
|
1373
|
-
|
|
1374
|
-
/**
|
|
1375
|
-
* Returns a static string of the libplist version.
|
|
1376
|
-
*
|
|
1377
|
-
* @return The libplist version as static ascii string
|
|
1378
|
-
*/
|
|
1379
|
-
PLIST_API const char* libplist_version();
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
/********************************************
|
|
1383
|
-
* *
|
|
1384
|
-
* Deprecated API *
|
|
1385
|
-
* *
|
|
1386
|
-
********************************************/
|
|
1387
|
-
|
|
1388
|
-
/**
|
|
1389
|
-
* Create a new plist_t type #PLIST_DATE
|
|
1390
|
-
*
|
|
1391
|
-
* @deprecated Deprecated. Use plist_new_unix_date instead.
|
|
1392
|
-
*
|
|
1393
|
-
* @param sec the number of seconds since 01/01/2001
|
|
1394
|
-
* @param usec the number of microseconds
|
|
1395
|
-
* @return the created item
|
|
1396
|
-
* @sa #plist_type
|
|
1397
|
-
*/
|
|
1398
|
-
PLIST_WARN_DEPRECATED("use plist_new_unix_date instead")
|
|
1399
|
-
PLIST_API plist_t plist_new_date(int32_t sec, int32_t usec);
|
|
1400
|
-
|
|
1401
|
-
/**
|
|
1402
|
-
* Get the value of a #PLIST_DATE node.
|
|
1403
|
-
* This function does nothing if node is not of type #PLIST_DATE
|
|
1404
|
-
*
|
|
1405
|
-
* @deprecated Deprecated. Use plist_get_unix_date_val instead.
|
|
1406
|
-
*
|
|
1407
|
-
* @param node the node
|
|
1408
|
-
* @param sec a pointer to an int32_t variable. Represents the number of seconds since 01/01/2001.
|
|
1409
|
-
* @param usec a pointer to an int32_t variable. Represents the number of microseconds
|
|
1410
|
-
*/
|
|
1411
|
-
PLIST_WARN_DEPRECATED("use plist_get_unix_date_val instead")
|
|
1412
|
-
PLIST_API void plist_get_date_val(plist_t node, int32_t * sec, int32_t * usec);
|
|
1413
|
-
|
|
1414
|
-
/**
|
|
1415
|
-
* Set the value of a node.
|
|
1416
|
-
* Forces type of node to #PLIST_DATE
|
|
1417
|
-
*
|
|
1418
|
-
* @deprecated Deprecated. Use plist_set_unix_date_val instead.
|
|
1419
|
-
*
|
|
1420
|
-
* @param node the node
|
|
1421
|
-
* @param sec the number of seconds since 01/01/2001
|
|
1422
|
-
* @param usec the number of microseconds
|
|
1423
|
-
*/
|
|
1424
|
-
PLIST_WARN_DEPRECATED("use plist_set_unix_date_val instead")
|
|
1425
|
-
PLIST_API void plist_set_date_val(plist_t node, int32_t sec, int32_t usec);
|
|
1426
|
-
|
|
1427
|
-
/**
|
|
1428
|
-
* Helper function to compare the value of a PLIST_DATE node against
|
|
1429
|
-
* a given set of seconds and fraction of a second since epoch.
|
|
1430
|
-
*
|
|
1431
|
-
* @deprecated Deprecated. Use plist_unix_date_val_compare instead.
|
|
1432
|
-
*
|
|
1433
|
-
* @param datenode node of type PLIST_DATE
|
|
1434
|
-
* @param cmpsec number of seconds since epoch to compare against
|
|
1435
|
-
* @param cmpusec fraction of a second in microseconds to compare against
|
|
1436
|
-
* @return 0 if the node's date is equal to the supplied values,
|
|
1437
|
-
* 1 if the node's date is greater than the supplied values,
|
|
1438
|
-
* or -1 if the node's date is less than the supplied values.
|
|
1439
|
-
*/
|
|
1440
|
-
PLIST_WARN_DEPRECATED("use plist_unix_date_val_compare instead")
|
|
1441
|
-
PLIST_API int plist_date_val_compare(plist_t datenode, int32_t cmpsec, int32_t cmpusec);
|
|
1442
|
-
|
|
1443
|
-
/*@}*/
|
|
1444
|
-
|
|
1445
|
-
#ifdef __cplusplus
|
|
1446
|
-
}
|
|
1447
|
-
#endif
|
|
1448
|
-
#endif
|