Skip to content

Commit

Permalink
Kernel arch
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Morris authored and Michael Morris committed Mar 14, 2011
1 parent f72f1b2 commit b847297
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 7 deletions.
3 changes: 2 additions & 1 deletion Classes/Headers/NSStringHelper.h
Expand Up @@ -11,6 +11,7 @@

@interface NSString (NSStringHelper)
+ (id)stringWithBytes:(const void *)bytes length:(NSUInteger)length encoding:(NSStringEncoding)encoding;
+ (id)stringWithData:(NSData *)data encoding:(NSStringEncoding)encoding;

- (NSString *)safeSubstringAfterIndex:(NSInteger)anIndex;
- (NSString *)safeSubstringBeforeIndex:(NSInteger)anIndex;
Expand Down Expand Up @@ -108,4 +109,4 @@
- (id)safeAttribute:(NSString *)attrName atIndex:(NSUInteger)location longestEffectiveRange:(NSRangePointer)range inRange:(NSRange)rangeLimit;

- (NSDictionary *)safeAttributesAtIndex:(NSUInteger)location longestEffectiveRange:(NSRangePointer)range inRange:(NSRange)rangeLimit;
@end
@end
7 changes: 6 additions & 1 deletion Classes/Helpers/NSStringHelper.m
Expand Up @@ -12,6 +12,11 @@ + (id)stringWithBytes:(const void *)bytes length:(NSUInteger)length encoding:(NS
return [[[NSString alloc] initWithBytes:bytes length:length encoding:encoding] autodrain];
}

+ (id)stringWithData:(NSData *)data encoding:(NSStringEncoding)encoding
{
return [[[NSString alloc] initWithData:data encoding:encoding] autodrain];
}

- (NSString *)safeSubstringWithRange:(NSRange)range;
{
if (range.location == NSNotFound) return nil;
Expand Down Expand Up @@ -54,7 +59,7 @@ - (NSString *)fastChopEndWithChars:(NSArray *)chars
NSString *strChopper = self;

for (NSInteger i = 1; i < slnt; i++) {
slchar = [strChopper safeSubstringFromIndex:([strChopper length] - 1)];
slchar = [strChopper safeSubstringFromIndex:([strChopper length] - 1)];
strChopper = [strChopper safeSubstringToIndex:([strChopper length] - 1)];

if ([chars containsObject:slchar] == NO) {
Expand Down
8 changes: 5 additions & 3 deletions Classes/IRC/IRCClient.m
Expand Up @@ -4868,15 +4868,17 @@ - (void)ircConnectionDidError:(NSString *)error

- (void)ircConnectionDidReceive:(NSData *)data
{
NSString *s = [[[NSString alloc] initWithData:data encoding:encoding] autodrain];
NSString *s = [NSString stringWithData:data encoding:encoding];

if (PointerIsEmpty(s)) {
s = [[[NSString alloc] initWithData:data encoding:config.fallbackEncoding] autodrain];
s = [NSString stringWithData:data encoding:config.fallbackEncoding];

if (PointerIsEmpty(s)) {
s = [[[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding] autodrain];
s = [NSString stringWithData:data encoding:NSUTF8StringEncoding];

if (PointerIsEmpty(s)) {
NSLog(@"NSData decode failure. (%@)", data);

return;
}
}
Expand Down
5 changes: 3 additions & 2 deletions Classes/Others/ValidateReceipt.m
Expand Up @@ -62,8 +62,9 @@
list.attr = attributes;

SecKeychainItemCopyContent(itemRef, nil, &list, nil, nil);
NSData *nameData = [NSData dataWithBytesNoCopy:attributes[0].data length:attributes[0].length freeWhenDone:NO];
NSString *name = [[NSString alloc] initWithData:nameData encoding:NSUTF8StringEncoding];

NSData *nameData = [NSData dataWithBytesNoCopy:attributes[0].data length:attributes[0].length freeWhenDone:NO];
NSString *name = [NSString stringWithData:nameData encoding:NSUTF8StringEncoding];

if ([name isEqualToString:@"Apple Root CA"]) {
CSSM_DATA certData;
Expand Down
1 change: 1 addition & 0 deletions Resources/Plugins/SystemProfiler/SystemProfiler.pch
Expand Up @@ -10,6 +10,7 @@
#include <sys/types.h>
#include <sys/sysctl.h>
#include <sys/socket.h>
#include <sys/utsname.h>

#include <ifaddrs.h>
#include <net/if.h>
Expand Down
1 change: 1 addition & 0 deletions Resources/Plugins/SystemProfiler/TPI_SP_SysInfo.h
Expand Up @@ -9,6 +9,7 @@
+ (NSString *)processorL2CacheSize;
+ (NSString *)processorL3CacheSize;
+ (NSString *)processorClockSpeed;
+ (NSString *)kernelArchitecture;
+ (NSString *)physicalMemorySize;
+ (NSString *)loadAveragesWithCores:(NSInteger)cores;
+ (NSString *)systemUptime;
Expand Down
23 changes: 23 additions & 0 deletions Resources/Plugins/SystemProfiler/TPI_SP_SysInfo.m
Expand Up @@ -83,6 +83,12 @@ + (NSString *)compiledOutput
[[Preferences systemInfoPlist] objectForKey:@"ProductVersion"],
[[Preferences systemInfoPlist] objectForKey:@"ProductBuildVersion"]];

NSString *arch = [self kernelArchitecture];

if (NSObjectIsNotEmpty(arch)) {
sysinfo = [sysinfo stringByAppendingFormat:@" (%@ kernel)", arch];
}

return sysinfo;
}

Expand Down Expand Up @@ -474,6 +480,23 @@ + (NSString *)processorClockSpeed
}
}

+ (NSString *)kernelArchitecture
{
struct utsname name;

if (uname(&name) >= 0) {
NSString *machine = [NSString stringWithFormat:@"%s", name.machine];

if ([machine isEqualToString:@"x86_64"]) {
return @"64-bit";
} else {
return @"32-bit";
}
}

return nil;
}

+ (NSString *)physicalMemorySize
{
uint64_t linesize = 0L;
Expand Down

0 comments on commit b847297

Please sign in to comment.