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 test1_start
;
30 kmod_stop_func_t test1_stop
;
33 #include <libkern/c++/OSContainers.h>
34 #include <iokit/IOLib.h>
37 { string = \"this is a 'string' with spaces\";
38 string2 = 'this is also a \"string\" with spaces';
42 data = <0123 4567 89abcdef>;
43 array = (1:8, 2:16, 3:32, 4:64 );
44 set = [ one, two, three, four ];
53 dict2 = { string = asdfasdf; };
54 dict3 = { string = asdfasdf; };
58 test1_start(struct kmod_info
*ki
, void *data
)
60 IOLog("test buffer start:\n%s\n:test buffer end.\n", testBuffer
);
64 OSObject
*d
= OSUnserialize(testBuffer
, &errmsg
);
66 IOLog("%s\n", errmsg
->getCStringNoCopy());
67 return KMOD_RETURN_SUCCESS
;
71 OSSerialize
*s
= OSSerialize::withCapacity(5);
72 if (!d
->serialize(s
)) {
73 IOLog("serialization failed\n");
74 return KMOD_RETURN_SUCCESS
;
77 IOLog("serialized object's length = %d, capacity = %d\n", s
->getLength(), s
->getCapacity());
78 IOLog("object unformatted = %s\n", s
->text());
81 OSObject
*d2
= OSUnserializeXML(s
->text(), &errmsg
);
83 IOLog("%s\n", errmsg
->getCStringNoCopy());
84 return KMOD_RETURN_SUCCESS
;
87 IOLog("\nserialized objects compared %ssuccessfully objectwise\n\n",
88 d
->isEqualTo(d2
) ? "":"un");
90 if (d2
) d2
->release();
94 return KMOD_RETURN_SUCCESS
;
98 test1_stop(struct kmod_info
*ki
, void *data
)
100 return KMOD_RETURN_SUCCESS
;