Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from carlj/master
Fixes for iOS 5.1 and Xcode 4.3.1
- Loading branch information
Showing
8 changed files
with
328 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,25 @@ | ||
build | ||
*.DS_Store | ||
*.mode1v3 | ||
*.pbxuser | ||
*.bak | ||
.~* | ||
._* | ||
Thumbs.db | ||
project.pbxproj.mergesave | ||
doxygen.config | ||
|
||
# Exclude the build directory | ||
build/* | ||
|
||
# Exclude temp nibs and swap files | ||
*~.nib | ||
*.swp | ||
|
||
# Exclude OS X folder attributes | ||
.DS_Store | ||
|
||
# Exclude user-specific XCode 3 and 4 files | ||
*.mode1 | ||
*.mode1v3 | ||
*.mode2v3 | ||
*.perspective | ||
*.perspectivev3 | ||
*.pbxuser | ||
*.xcworkspace | ||
xcuserdata | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// MacAdress.h | ||
// CrashManager | ||
// | ||
// Created by Carl Jahn on 03.04.12. | ||
// | ||
// Copyright 2010 Karl Stenerud | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// Note: You are NOT required to make the license available from within your | ||
// iOS application. Including it in your project is sufficient. | ||
// | ||
// Attribution is not required, but appreciated :) | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface MacAdress : NSObject | ||
|
||
+ (NSString *)macAdress; | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// | ||
// MacAdress.m | ||
// VRM News | ||
// | ||
// Created by Carl Jahn on 21.11.11. | ||
// Copyright (c) 2011 NIDAG. All rights reserved. | ||
// | ||
|
||
#import "MacAdress.h" | ||
|
||
#include <sys/socket.h> | ||
#include <sys/sysctl.h> | ||
#include <net/if.h> | ||
#include <net/if_dl.h> | ||
|
||
|
||
|
||
@implementation MacAdress | ||
|
||
|
||
|
||
+ (NSString *)macAdress | ||
{ | ||
|
||
int mgmtInfoBase[6]; | ||
char *msgBuffer = NULL; | ||
NSString *errorFlag = NULL; | ||
size_t length; | ||
|
||
// Setup the management Information Base (mib) | ||
mgmtInfoBase[0] = CTL_NET; // Request network subsystem | ||
mgmtInfoBase[1] = AF_ROUTE; // Routing table info | ||
mgmtInfoBase[2] = 0; | ||
mgmtInfoBase[3] = AF_LINK; // Request link layer information | ||
mgmtInfoBase[4] = NET_RT_IFLIST; // Request all configured interfaces | ||
|
||
// With all configured interfaces requested, get handle index | ||
if ((mgmtInfoBase[5] = if_nametoindex("en0")) == 0) | ||
errorFlag = @"if_nametoindex failure"; | ||
// Get the size of the data available (store in len) | ||
else if (sysctl(mgmtInfoBase, 6, NULL, &length, NULL, 0) < 0) | ||
errorFlag = @"sysctl mgmtInfoBase failure"; | ||
// Alloc memory based on above call | ||
else if ((msgBuffer = malloc(length)) == NULL) | ||
errorFlag = @"buffer allocation failure"; | ||
// Get system information, store in buffer | ||
else if (sysctl(mgmtInfoBase, 6, msgBuffer, &length, NULL, 0) < 0) | ||
{ | ||
free(msgBuffer); | ||
errorFlag = @"sysctl msgBuffer failure"; | ||
} | ||
else | ||
{ | ||
// Map msgbuffer to interface message structure | ||
struct if_msghdr *interfaceMsgStruct = (struct if_msghdr *) msgBuffer; | ||
|
||
// Map to link-level socket structure | ||
struct sockaddr_dl *socketStruct = (struct sockaddr_dl *) (interfaceMsgStruct + 1); | ||
|
||
// Copy link layer address data in socket structure to an array | ||
unsigned char macAddress[6]; | ||
memcpy(&macAddress, socketStruct->sdl_data + socketStruct->sdl_nlen, 6); | ||
|
||
// Read from char array into a string object, into traditional Mac address format | ||
NSString *macAddressString = [NSString stringWithFormat:@"%02X:%02X:%02X:%02X:%02X:%02X", | ||
macAddress[0], macAddress[1], macAddress[2], macAddress[3], macAddress[4], macAddress[5]]; | ||
NSLog(@"Mac Address: %@", macAddressString); | ||
|
||
// Release the buffer memory | ||
free(msgBuffer); | ||
|
||
return macAddressString; | ||
} | ||
|
||
// Error... | ||
NSLog(@"Error: %@", errorFlag); | ||
|
||
return errorFlag; | ||
|
||
} | ||
|
||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// NSString+SHA.h | ||
// CrashManager | ||
// | ||
// Created by Carl Jahn on 03.04.12. | ||
// | ||
// Copyright 2012 Carl Jahn | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// Note: You are NOT required to make the license available from within your | ||
// iOS application. Including it in your project is sufficient. | ||
// | ||
// Attribution is not required, but appreciated :) | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface NSString (SHA) | ||
|
||
- (NSString *)sha1; | ||
- (NSString *)sha224; | ||
- (NSString *)sha256; | ||
- (NSString *)sha384; | ||
- (NSString *)sha512; | ||
|
||
|
||
@end |
Oops, something went wrong.