2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
22 #include <libkern/OSBase.h>
25 #include <mach/mach_types.h>
26 #include <mach/vm_types.h>
27 #include <mach/kmod.h>
29 kmod_start_func_t test2_start
;
30 kmod_stop_func_t test2_stop
;
33 #include <libkern/c++/OSContainers.h>
34 #include <iokit/IOLib.h>
37 <?xml version=\"1.0\" encoding=\"UTF-8\"?>
38 <!DOCTYPE plist SYSTEM \"file://localhost/System/Library/DTDs/PropertyList.dtd\">
39 <plist version=\"0.9\">
42 <key>key true</key> <true/>
43 <key>key false</key> <false/>
45 <key>key d0</key> <data> </data>
46 <key>key d1</key> <data>AQ==</data>
47 <key>key d2</key> <data>ASM=</data>
48 <key>key d3</key> <data>ASNF</data>
49 <key>key d4</key> <data format=\"hex\">0123 4567 89abcdef</data>
50 <key>key d5</key> <data ID=\"1\">ASNFZw==</data>
52 <key>key i0</key> <integer></integer>
53 <key>key i1</key> <integer>123456789</integer>
54 <key>key i2</key> <integer size=\"32\" ID=\"2\">0x12345678</integer>
56 <key>key s0</key> <string></string>
57 <key>key s1</key> <string>string 1</string>
58 <key>key s2</key> <string ID=\"3\">string 2</string>
59 <key>key <&></key> <string><&></string>
61 <key>key c0</key> <dict ID=\"4\">
64 <key>key a0</key> <array>
67 <key>key a1</key> <array ID=\"5\">
68 <string>array string 1</string>
69 <string>array string 2</string>
72 <key>key t0</key> <set>
74 <key>key t1</key> <set ID=\"6\">
75 <string>set string 1</string>
76 <string>set string 2</string>
79 <key>key r1</key> <ref IDREF=\"1\"/>
80 <key>key r2</key> <ref IDREF=\"2\"/>
81 <key>key r3</key> <ref IDREF=\"3\"/>
82 <key>key r4</key> <ref IDREF=\"4\"/>
83 <key>key r5</key> <ref IDREF=\"5\"/>
84 <key>key r6</key> <ref IDREF=\"6\"/>
86 <key>key e1</key> <array/>
87 <key>key e2</key> <dict/>
88 <key>key e3</key> <set/>
89 <key>key e4</key> <integer/>
90 <key>key e5</key> <string/>
91 <key>key e6</key> <data/>
98 this causes the parser to return an empty string? it doesn't look like yyerror gets called
99 char *testBuffer = "<array ID=1><array IDREF=\"1\"/></array>"
104 test2_start(struct kmod_info
*ki
, void *data
)
106 IOLog("test buffer start:\n%s\n:test buffer end.\n", testBuffer
);
109 OSString
*errmsg
= 0;
110 OSObject
*d
= OSUnserializeXML(testBuffer
, &errmsg
);
113 IOLog("%s\n", errmsg
->getCStringNoCopy());
115 IOLog("bogus error message\n");
117 return KMOD_RETURN_SUCCESS
;
121 OSSerialize
*s
= OSSerialize::withCapacity(5);
122 if (!d
->serialize(s
)) {
123 IOLog("serialization failed\n");
124 return KMOD_RETURN_SUCCESS
;
127 IOLog("serialized object's length = %d, capacity = %d\n", s
->getLength(), s
->getCapacity());
128 IOLog("object unformatted = %s\n", s
->text());
131 OSObject
*d2
= OSUnserializeXML(s
->text(), &errmsg
);
133 IOLog("%s\n", errmsg
->getCStringNoCopy());
134 return KMOD_RETURN_SUCCESS
;
136 OSSerialize
*s2
= OSSerialize::withCapacity(5);
137 if (!d2
->serialize(s2
)) {
138 IOLog("serialization #2 failed\n");
139 return KMOD_RETURN_SUCCESS
;
142 IOLog("serialized object's length = %d, capacity = %d\n",
143 s2
->getLength(), s2
->getCapacity());
144 IOLog("object unformatted = %s\n", s2
->text());
146 IOLog("\nserialized objects compared %ssuccessfully textually\n\n",
147 strcmp(s
->text(), s2
->text()) ? "un":"");
149 IOLog("\nserialized objects compared %ssuccessfully objectwise\n\n",
150 d
->isEqualTo(d2
) ? "":"un");
153 if (d2
) d2
->release();
157 return KMOD_RETURN_SUCCESS
;
161 test2_stop(struct kmod_info
*ki
, void *data
)
163 return KMOD_RETURN_SUCCESS
;