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 test1_start
;
33 kmod_stop_func_t test1_stop
;
36 #include <libkern/c++/OSContainers.h>
37 #include <iokit/IOLib.h>
40 { string = \"this is a 'string' with spaces\";
41 string2 = 'this is also a \"string\" with spaces';
45 data = <0123 4567 89abcdef>;
46 array = (1:8, 2:16, 3:32, 4:64 );
47 set = [ one, two, three, four ];
56 dict2 = { string = asdfasdf; };
57 dict3 = { string = asdfasdf; };
61 test1_start(struct kmod_info
*ki
, void *data
)
63 IOLog("test buffer start:\n%s\n:test buffer end.\n", testBuffer
);
67 OSObject
*d
= OSUnserialize(testBuffer
, &errmsg
);
69 IOLog("%s\n", errmsg
->getCStringNoCopy());
70 return KMOD_RETURN_SUCCESS
;
74 OSSerialize
*s
= OSSerialize::withCapacity(5);
75 if (!d
->serialize(s
)) {
76 IOLog("serialization failed\n");
77 return KMOD_RETURN_SUCCESS
;
80 IOLog("serialized object's length = %d, capacity = %d\n", s
->getLength(), s
->getCapacity());
81 IOLog("object unformatted = %s\n", s
->text());
84 OSObject
*d2
= OSUnserializeXML(s
->text(), &errmsg
);
86 IOLog("%s\n", errmsg
->getCStringNoCopy());
87 return KMOD_RETURN_SUCCESS
;
90 IOLog("\nserialized objects compared %ssuccessfully objectwise\n\n",
91 d
->isEqualTo(d2
) ? "":"un");
93 if (d2
) d2
->release();
97 return KMOD_RETURN_SUCCESS
;
101 test1_stop(struct kmod_info
*ki
, void *data
)
103 return KMOD_RETURN_SUCCESS
;