1 | //␊ |
2 | // ChameleonPrefPane␊ |
3 | //␊ |
4 | // test utility for the chameleon preference pane ␊ |
5 | //␊ |
6 | // Created by Rekursor on 11-11-12.␊ |
7 | //␊ |
8 | ␊ |
9 | #import <Foundation/Foundation.h>␊ |
10 | #import "PartitionInfoElement.h"␊ |
11 | #import "PartitionInfoManager.h"␊ |
12 | #import "SmbiosExtractor.h"␊ |
13 | #import "ShellProcess.h"␊ |
14 | #include "string_util.h"␊ |
15 | #include <string>␊ |
16 | #include <iostream>␊ |
17 | ␊ |
18 | void testDiskInfoWith(NSString * bsd)␊ |
19 | {␊ |
20 | ␉PartitionInfoElement* di = [[PartitionInfoElement alloc] initWithBSDName: bsd];␊ |
21 | ␉␊ |
22 | ␉if ([di isValid] && [di.vUUID length] >0)␊ |
23 | ␉{␊ |
24 | #if 0␊ |
25 | ␉␉NSLog(@"bsdName %@", [di bsdName] );␊ |
26 | ␉␉NSLog(@"deviceProtocol %@", [ di devProtocol] );␊ |
27 | ␉␉NSLog(@"volumeName %@", [di vName]);␊ |
28 | ␉␉NSLog(@"volumeKind %@", [di vKind]);␊ |
29 | ␉␉NSLog(@"deviceInternal %i", (int) [ di devInternal] );␊ |
30 | ␉␉NSLog(@"volumeUUID %@", [di vUUID]);␊ |
31 | ␉␉NSLog(@"mediaPath %@", [di mediaPath]);␊ |
32 | ␉␉NSLog(@"mediaRemovable %i", (int) [di mediaRemovable]);␊ |
33 | ␉␉␊ |
34 | ␉␉NSLog(@"\n");␊ |
35 | ␊ |
36 | #else␊ |
37 | ␉␉int i = 0;␊ |
38 | ␉␉for (NSString* o in di.descDict)␊ |
39 | ␉␉{␊ |
40 | ␉␉ id value = [di.descDict objectForKey: o];␊ |
41 | ␉␉ if (value == nil) value = @"<nil>";␊ |
42 | ␉␉ NSLog(@"Key: %@, Value: %@", o, value );␊ |
43 | ␉␉ i++;␊ |
44 | ␉␉}␊ |
45 | #endif␊ |
46 | ␉}␊ |
47 | ␊ |
48 | ␉[di release];␊ |
49 | }␊ |
50 | ␊ |
51 | int main (int argc, const char * argv[]) ␊ |
52 | {␊ |
53 | NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];␊ |
54 | ␉␊ |
55 | ␉SmbiosExtractor* smbe = [[SmbiosExtractor alloc] init];␊ |
56 | ␉[smbe save:@"/tmp/chmIOreg.plist"];␊ |
57 | ␉NSLog(@"SMBIOS = \n%@", smbe); ␊ |
58 | ␉␊ |
59 | #if 1␊ |
60 | ␉NSArray* arr = [PartitionInfoElement createBSDPartitionList];␊ |
61 | ␉NSLog(@"List of existing bsd disk partitions:\n %@", arr);␊ |
62 | ␉␊ |
63 | ␉for (PartitionInfoElement* part in [PartsInfoMgr parts]) ␊ |
64 | ␉␉NSLog(@"PartionBootable = %i\n%@", (int) [part isBootable], part);␊ |
65 | /*␊ |
66 | ␉[PartsInfoMgr hideParts: @"\"Macintosh HD\" hd(0,3)"];␊ |
67 | ␉[PartsInfoMgr hideParts: @"disk0s2 hd(0,2) "];␊ |
68 | ␉[PartsInfoMgr hideParts: @"BOOTCAMP \"Macintosh HD\""];␊ |
69 | ␉[PartsInfoMgr hideParts: @"3E9C6A92-3737-4C0F-9003-20B2482D61FB"];␊ |
70 | */␊ |
71 | ␉[PartsInfoMgr renameParts: @"hd(0,2) \"Test\""];␊ |
72 | ␉[PartsInfoMgr renameParts: @"hd(0,3) Fantastic"];␊ |
73 | ␉[PartsInfoMgr renameParts: @"hd(0,4) \"A BC\"; hd(0,2) DEF"];␊ |
74 | ␉␊ |
75 | #else␊ |
76 | ␉testDiskInfoWith(@"disk0s2");␉␊ |
77 | ␉testDiskInfoWith(@"disk0s3");␉␊ |
78 | #endif␊ |
79 | fprintf(stderr, "String Test\n");␊ |
80 | std::string options = "-v darkwake ab= a=0 =abc -f";␊ |
81 | fprintf(stderr, "options = %s\n", options.c_str() );␊ |
82 | std::list<std::string> l = tokenize(options, " ");␊ |
83 | std::list<std::string>::const_iterator it = l.begin();␊ |
84 | for (; it != l.end(); it++)␊ |
85 | {␊ |
86 | std::string s = *it;␊ |
87 | std::cerr << "token: " << s ␊ |
88 | << ", left: " << string_left(s, "=") ␊ |
89 | << ", right: " << string_right(s, "=") ␊ |
90 | << ", trim: " << trim(s) ␊ |
91 | << std::endl;␊ |
92 | }␊ |
93 | ␊ |
94 | [pool drain];␊ |
95 | return 0;␊ |
96 | }␊ |
97 | |