Skip to content

Commit

Permalink
Merge pull request #2 from carlj/master
Browse files Browse the repository at this point in the history
Fixes for iOS 5.1 and Xcode 4.3.1
  • Loading branch information
kstenerud committed Apr 3, 2012
2 parents 9d3bda7 + d8ec771 commit a3e8dff
Show file tree
Hide file tree
Showing 8 changed files with 328 additions and 17 deletions.
27 changes: 21 additions & 6 deletions .gitignore
@@ -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

21 changes: 17 additions & 4 deletions CrashManager.xcodeproj/project.pbxproj
Expand Up @@ -3,10 +3,12 @@
archiveVersion = 1;
classes = {
};
objectVersion = 45;
objectVersion = 46;
objects = {

/* Begin PBXBuildFile section */
15B5B521152AF3170042EA2E /* MacAdress.m in Sources */ = {isa = PBXBuildFile; fileRef = 15B5B520152AF3170042EA2E /* MacAdress.m */; };
15B5B527152AF4E80042EA2E /* NSString+SHA.m in Sources */ = {isa = PBXBuildFile; fileRef = 15B5B526152AF4E80042EA2E /* NSString+SHA.m */; };
1D3623260D0F684500981E51 /* CrashManagerDemoAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* CrashManagerDemoAppDelegate.m */; };
1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; };
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
Expand All @@ -23,6 +25,10 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
15B5B51F152AF3170042EA2E /* MacAdress.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacAdress.h; sourceTree = "<group>"; };
15B5B520152AF3170042EA2E /* MacAdress.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MacAdress.m; sourceTree = "<group>"; };
15B5B525152AF4E80042EA2E /* NSString+SHA.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+SHA.h"; sourceTree = "<group>"; };
15B5B526152AF4E80042EA2E /* NSString+SHA.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+SHA.m"; sourceTree = "<group>"; };
1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
1D3623240D0F684500981E51 /* CrashManagerDemoAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrashManagerDemoAppDelegate.h; sourceTree = "<group>"; };
1D3623250D0F684500981E51 /* CrashManagerDemoAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CrashManagerDemoAppDelegate.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -151,6 +157,10 @@
isa = PBXGroup;
children = (
39EF1F111299EC6B00261349 /* SynthesizeSingleton.h */,
15B5B51F152AF3170042EA2E /* MacAdress.h */,
15B5B520152AF3170042EA2E /* MacAdress.m */,
15B5B525152AF4E80042EA2E /* NSString+SHA.h */,
15B5B526152AF4E80042EA2E /* NSString+SHA.m */,
);
path = Support;
sourceTree = "<group>";
Expand Down Expand Up @@ -191,8 +201,11 @@
/* Begin PBXProject section */
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0430;
};
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "CrashManager" */;
compatibilityVersion = "Xcode 3.1";
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
Expand Down Expand Up @@ -234,6 +247,8 @@
39EF1F181299EC6B00261349 /* StackTracer.m in Sources */,
39EF1F191299EC6B00261349 /* Mailer.m in Sources */,
39EF1F1A1299EC6B00261349 /* ModalViewPresenter.m in Sources */,
15B5B521152AF3170042EA2E /* MacAdress.m in Sources */,
15B5B527152AF4E80042EA2E /* NSString+SHA.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -275,7 +290,6 @@
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
SDKROOT = iphoneos;
};
name = Debug;
Expand All @@ -289,7 +303,6 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
PREBINDING = NO;
SDKROOT = iphoneos;
};
name = Release;
Expand Down
7 changes: 4 additions & 3 deletions libs/CrashManager/CrashManager.m
Expand Up @@ -28,7 +28,8 @@
#include <unistd.h>
#import "StackTracer.h"
#import <UIKit/UIKit.h>

#import "MacAdress.h"
#import "NSString+SHA.h"

/** Maximum number of stack frames to capture. */
#define kStackFramesToCapture 40
Expand Down Expand Up @@ -256,8 +257,8 @@ - (void) storeErrorReport:(NSException*) exception stackTrace:(NSArray*) stackTr
NSString* data = [NSString stringWithFormat:@"App: %@\nVersion: %@\nID: %@\n%@: %@\n%@",
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"],
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"],
[UIDevice currentDevice].uniqueIdentifier,
[exception name],
[[MacAdress macAdress] sha1],
[exception name],
[exception reason],
[[StackTracer sharedInstance] printableTrace:stackTrace]];
[data writeToFile:errorReportPath atomically:YES encoding:NSUTF8StringEncoding error:nil];
Expand Down
34 changes: 34 additions & 0 deletions libs/CrashManager/Support/MacAdress.h
@@ -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
84 changes: 84 additions & 0 deletions libs/CrashManager/Support/MacAdress.m
@@ -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
38 changes: 38 additions & 0 deletions libs/CrashManager/Support/NSString+SHA.h
@@ -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

0 comments on commit a3e8dff

Please sign in to comment.