2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 #include <libkern/OSBase.h>
28 #include <mach/mach_types.h>
29 #include <mach/vm_types.h>
30 #include <mach/kmod.h>
32 kmod_start_func_t test2_start
;
33 kmod_stop_func_t test2_stop
;
36 #include <libkern/c++/OSContainers.h>
37 #include <iokit/IOLib.h>
40 <?xml version=\"1.0\" encoding=\"UTF-8\"?>
41 <!DOCTYPE plist SYSTEM \"file://localhost/System/Library/DTDs/PropertyList.dtd\">
42 <plist version=\"0.9\">
45 <key>key true</key> <true/>
46 <key>key false</key> <false/>
48 <key>key d0</key> <data> </data>
49 <key>key d1</key> <data>AQ==</data>
50 <key>key d2</key> <data>ASM=</data>
51 <key>key d3</key> <data>ASNF</data>
52 <key>key d4</key> <data format=\"hex\">0123 4567 89abcdef</data>
53 <key>key d5</key> <data ID=\"1\">ASNFZw==</data>
55 <key>key i0</key> <integer></integer>
56 <key>key i1</key> <integer>123456789</integer>
57 <key>key i2</key> <integer size=\"32\" ID=\"2\">0x12345678</integer>
59 <key>key s0</key> <string></string>
60 <key>key s1</key> <string>string 1</string>
61 <key>key s2</key> <string ID=\"3\">string 2</string>
62 <key>key <&></key> <string><&></string>
64 <key>key c0</key> <dict ID=\"4\">
67 <key>key a0</key> <array>
70 <key>key a1</key> <array ID=\"5\">
71 <string>array string 1</string>
72 <string>array string 2</string>
75 <key>key t0</key> <set>
77 <key>key t1</key> <set ID=\"6\">
78 <string>set string 1</string>
79 <string>set string 2</string>
82 <key>key r1</key> <ref IDREF=\"1\"/>
83 <key>key r2</key> <ref IDREF=\"2\"/>
84 <key>key r3</key> <ref IDREF=\"3\"/>
85 <key>key r4</key> <ref IDREF=\"4\"/>
86 <key>key r5</key> <ref IDREF=\"5\"/>
87 <key>key r6</key> <ref IDREF=\"6\"/>
89 <key>key e1</key> <array/>
90 <key>key e2</key> <dict/>
91 <key>key e3</key> <set/>
92 <key>key e4</key> <integer/>
93 <key>key e5</key> <string/>
94 <key>key e6</key> <data/>
101 this causes the parser to return an empty string? it doesn't look like yyerror gets called
102 char *testBuffer = "<array ID=1><array IDREF=\"1\"/></array>"
107 test2_start(struct kmod_info
*ki
, void *data
)
109 IOLog("test buffer start:\n%s\n:test buffer end.\n", testBuffer
);
112 OSString
*errmsg
= 0;
113 OSObject
*d
= OSUnserializeXML(testBuffer
, &errmsg
);
116 IOLog("%s\n", errmsg
->getCStringNoCopy());
118 IOLog("bogus error message\n");
120 return KMOD_RETURN_SUCCESS
;
124 OSSerialize
*s
= OSSerialize::withCapacity(5);
125 if (!d
->serialize(s
)) {
126 IOLog("serialization failed\n");
127 return KMOD_RETURN_SUCCESS
;
130 IOLog("serialized object's length = %d, capacity = %d\n", s
->getLength(), s
->getCapacity());
131 IOLog("object unformatted = %s\n", s
->text());
134 OSObject
*d2
= OSUnserializeXML(s
->text(), &errmsg
);
136 IOLog("%s\n", errmsg
->getCStringNoCopy());
137 return KMOD_RETURN_SUCCESS
;
139 OSSerialize
*s2
= OSSerialize::withCapacity(5);
140 if (!d2
->serialize(s2
)) {
141 IOLog("serialization #2 failed\n");
142 return KMOD_RETURN_SUCCESS
;
145 IOLog("serialized object's length = %d, capacity = %d\n",
146 s2
->getLength(), s2
->getCapacity());
147 IOLog("object unformatted = %s\n", s2
->text());
149 IOLog("\nserialized objects compared %ssuccessfully textually\n\n",
150 strcmp(s
->text(), s2
->text()) ? "un":"");
152 IOLog("\nserialized objects compared %ssuccessfully objectwise\n\n",
153 d
->isEqualTo(d2
) ? "":"un");
156 if (d2
) d2
->release();
160 return KMOD_RETURN_SUCCESS
;
164 test2_stop(struct kmod_info
*ki
, void *data
)
166 return KMOD_RETURN_SUCCESS
;