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