/src/libplist/src/plist.h
Line | Count | Source |
1 | | /* |
2 | | * plist.h |
3 | | * contains structures and the like for plists |
4 | | * |
5 | | * Copyright (c) 2008 Zach C. All Rights Reserved. |
6 | | * |
7 | | * This library is free software; you can redistribute it and/or |
8 | | * modify it under the terms of the GNU Lesser General Public |
9 | | * License as published by the Free Software Foundation; either |
10 | | * version 2.1 of the License, or (at your option) any later version. |
11 | | * |
12 | | * This library is distributed in the hope that it will be useful, |
13 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | | * Lesser General Public License for more details. |
16 | | * |
17 | | * You should have received a copy of the GNU Lesser General Public |
18 | | * License along with this library; if not, write to the Free Software |
19 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20 | | */ |
21 | | |
22 | | #ifndef PLIST_H |
23 | | #define PLIST_H |
24 | | |
25 | | #ifdef HAVE_CONFIG_H |
26 | | #include <config.h> |
27 | | #endif |
28 | | |
29 | | #include <sys/types.h> |
30 | | #include <sys/stat.h> |
31 | | |
32 | | #ifdef _MSC_VER |
33 | | #pragma warning(disable:4996) |
34 | | #pragma warning(disable:4244) |
35 | | #include <winsock2.h> |
36 | | #else |
37 | | #include <sys/time.h> |
38 | | #endif |
39 | | |
40 | | #ifdef LIBPLIST_STATIC |
41 | | #define PLIST_API |
42 | | #elif defined(_WIN32) |
43 | | #define PLIST_API __declspec( dllexport ) |
44 | | #else |
45 | | #if __GNUC__ >= 4 |
46 | | #define PLIST_API __attribute__((visibility("default"))) |
47 | | #else |
48 | | #define PLIST_API |
49 | | #endif |
50 | | #endif |
51 | | |
52 | | #include "node.h" |
53 | | |
54 | | #ifndef PLIST_MAX_NESTING_DEPTH |
55 | | #ifdef NODE_MAX_DEPTH |
56 | 499k | #define PLIST_MAX_NESTING_DEPTH NODE_MAX_DEPTH |
57 | | #else |
58 | | #define PLIST_MAX_NESTING_DEPTH 512 |
59 | | #endif |
60 | | #endif |
61 | | |
62 | | #include "plist/plist.h" |
63 | | |
64 | | struct plist_data_s |
65 | | { |
66 | | union |
67 | | { |
68 | | char boolval; |
69 | | uint64_t intval; |
70 | | double realval; |
71 | | char *strval; |
72 | | uint8_t *buff; |
73 | | void *hashtable; |
74 | | }; |
75 | | uint64_t length; |
76 | | plist_type type; |
77 | | }; |
78 | | |
79 | | typedef struct plist_data_s *plist_data_t; |
80 | | |
81 | | plist_t plist_new_node(plist_data_t data); |
82 | | plist_data_t plist_get_data(plist_t node); |
83 | | plist_data_t plist_new_plist_data(void); |
84 | | void plist_free_data(plist_data_t data); |
85 | | int plist_data_compare(const void *a, const void *b); |
86 | | |
87 | | extern plist_err_t plist_write_to_string_default(plist_t plist, char **output, uint32_t* length, plist_write_options_t options); |
88 | | extern plist_err_t plist_write_to_string_limd(plist_t plist, char **output, uint32_t* length, plist_write_options_t options); |
89 | | extern plist_err_t plist_write_to_string_plutil(plist_t plist, char **output, uint32_t* length, plist_write_options_t options); |
90 | | extern plist_err_t plist_write_to_stream_default(plist_t plist, FILE *stream, plist_write_options_t options); |
91 | | extern plist_err_t plist_write_to_stream_limd(plist_t plist, FILE *stream, plist_write_options_t options); |
92 | | extern plist_err_t plist_write_to_stream_plutil(plist_t plist, FILE *stream, plist_write_options_t options); |
93 | | |
94 | | static inline unsigned int plist_node_ptr_hash(const void *ptr) |
95 | 0 | { |
96 | 0 | uintptr_t h = (uintptr_t)ptr; |
97 | 0 | h ^= (h >> 16); |
98 | 0 | h *= 0x85ebca6b; |
99 | 0 | return (unsigned int)h; |
100 | 0 | } Unexecuted instantiation: jplist.c:plist_node_ptr_hash Unexecuted instantiation: plist.c:plist_node_ptr_hash Unexecuted instantiation: xplist.c:plist_node_ptr_hash Unexecuted instantiation: bplist.c:plist_node_ptr_hash Unexecuted instantiation: oplist.c:plist_node_ptr_hash Unexecuted instantiation: out-default.c:plist_node_ptr_hash Unexecuted instantiation: out-plutil.c:plist_node_ptr_hash Unexecuted instantiation: out-limd.c:plist_node_ptr_hash |
101 | | |
102 | | static inline int plist_node_ptr_compare(const void *a, const void *b) |
103 | 0 | { |
104 | 0 | return a == b; |
105 | 0 | } Unexecuted instantiation: jplist.c:plist_node_ptr_compare Unexecuted instantiation: plist.c:plist_node_ptr_compare Unexecuted instantiation: xplist.c:plist_node_ptr_compare Unexecuted instantiation: bplist.c:plist_node_ptr_compare Unexecuted instantiation: oplist.c:plist_node_ptr_compare Unexecuted instantiation: out-default.c:plist_node_ptr_compare Unexecuted instantiation: out-plutil.c:plist_node_ptr_compare Unexecuted instantiation: out-limd.c:plist_node_ptr_compare |
106 | | |
107 | | #endif |