2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
23 #include <libkern/OSBase.h>
26 #include <mach/mach_types.h>
27 #include <mach/vm_types.h>
28 #include <mach/kmod.h>
30 kmod_start_func_t test1_start
;
31 kmod_stop_func_t test1_stop
;
34 #include <libkern/c++/OSContainers.h>
35 #include <iokit/IOLib.h>
38 { string = \"this is a 'string' with spaces\";
39 string2 = 'this is also a \"string\" with spaces';
43 data = <0123 4567 89abcdef>;
44 array = (1:8, 2:16, 3:32, 4:64 );
45 set = [ one, two, three, four ];
54 dict2 = { string = asdfasdf; };
55 dict3 = { string = asdfasdf; };
59 test1_start(struct kmod_info
*ki
, void *data
)
61 IOLog("test buffer start:\n%s\n:test buffer end.\n", testBuffer
);
65 OSObject
*d
= OSUnserialize(testBuffer
, &errmsg
);
67 IOLog("%s\n", errmsg
->getCStringNoCopy());
68 return KMOD_RETURN_SUCCESS
;
72 OSSerialize
*s
= OSSerialize::withCapacity(5);
73 if (!d
->serialize(s
)) {
74 IOLog("serialization failed\n");
75 return KMOD_RETURN_SUCCESS
;
78 IOLog("serialized object's length = %d, capacity = %d\n", s
->getLength(), s
->getCapacity());
79 IOLog("object unformatted = %s\n", s
->text());
82 OSObject
*d2
= OSUnserializeXML(s
->text(), &errmsg
);
84 IOLog("%s\n", errmsg
->getCStringNoCopy());
85 return KMOD_RETURN_SUCCESS
;
88 IOLog("\nserialized objects compared %ssuccessfully objectwise\n\n",
89 d
->isEqualTo(d2
) ? "":"un");
91 if (d2
) d2
->release();
95 return KMOD_RETURN_SUCCESS
;
99 test1_stop(struct kmod_info
*ki
, void *data
)
101 return KMOD_RETURN_SUCCESS
;