Skip to content
Snippets Groups Projects
Commit 2b4790f4 authored by Tom Feist's avatar Tom Feist
Browse files

updated UKCrashReporter to squash most of its warnings

parent 3eecadd2
No related branches found
No related tags found
No related merge requests found
//
// UKCrashReporter.h
// NiftyFeatures
//
// Minor changes to function declarations to remove warnings
// -- Tom Feist, 5/6/2011
// Created by Uli Kusterer on Sat Feb 04 2006.
// Copyright (c) 2006 M. Uli Kusterer. All rights reserved.
//
Loading
Loading
@@ -26,7 +27,7 @@
URLs for different locales that way, in case a crash is caused by an error
in a localized file.
*/
void UKCrashReporterCheckForCrash();
void UKCrashReporterCheckForCrash(void);
 
 
// -----------------------------------------------------------------------------
Loading
Loading
//
// UKCrashReporter.m
// NiftyFeatures
// Minor changes (converting to try/catch, renaming expl which shadows a math function
// -- Tom Feist, 5/6/2011
//
// Created by Uli Kusterer on Sat Feb 04 2006.
// Copyright (c) 2006 M. Uli Kusterer. All rights reserved.
Loading
Loading
@@ -38,17 +40,18 @@ void UKCrashReporterCheckForCrash()
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NS_DURING
@try {
// Try whether the classes we need to talk to the CGI are present:
Class NSMutableURLRequestClass = NSClassFromString( @"NSMutableURLRequest" );
Class NSURLConnectionClass = NSClassFromString( @"NSURLConnection" );
Class NSMutableURLRequestClass = NSClassFromString( @"NSMutableURLRequest" );
Class NSURLConnectionClass = NSClassFromString( @"NSURLConnection" );
if( NSMutableURLRequestClass == Nil || NSURLConnectionClass == Nil )
{
[pool release];
NS_VOIDRETURN;
return;
}
long sysvMajor = 0, sysvMinor = 0, sysvBugfix = 0;
SInt32 sysvMajor = 0, sysvMinor = 0, sysvBugfix = 0;
UKGetSystemVersionComponents( &sysvMajor, &sysvMinor, &sysvBugfix );
BOOL isTenFiveOrBetter = sysvMajor >= 10 && sysvMinor >= 5;
Loading
Loading
@@ -89,11 +92,11 @@ void UKCrashReporterCheckForCrash()
[[UKCrashReporter alloc] initWithLogString: currentReport];
}
}
NS_HANDLER
NSLog(@"Error during check for crash: %@",localException);
NS_ENDHANDLER
[pool release];
} @catch (NSException *exception) {
NSLog(@"Error during check for crash: %@", exception);
} @finally {
[pool release];
}
}
 
NSString* UKCrashReporterFindTenFiveCrashReportPath( NSString* appName, NSString* crashLogsFolder )
Loading
Loading
@@ -174,14 +177,20 @@ NSString* gCrashLogString = nil;
{
// Insert the app name into the explanation message:
NSString* appName = [[NSFileManager defaultManager] displayNameAtPath: [[NSBundle mainBundle] bundlePath]];
NSMutableString* expl = nil;
if( gCrashLogString )
expl = [[[explanationField stringValue] mutableCopy] autorelease];
else
expl = [[NSLocalizedStringFromTable(@"FEEDBACK_EXPLANATION_TEXT",@"UKCrashReporter",@"") mutableCopy] autorelease];
[expl replaceOccurrencesOfString: @"%%APPNAME" withString: appName
options: 0 range: NSMakeRange(0, [expl length])];
[explanationField setStringValue: expl];
NSMutableString* explanation = nil;
if(gCrashLogString) {
explanation = [[[explanationField stringValue] mutableCopy] autorelease];
}else {
explanation = [[NSLocalizedStringFromTable
(@"FEEDBACK_EXPLANATION_TEXT",
@"UKCrashReporter",@"") mutableCopy] autorelease];
}
[explanation replaceOccurrencesOfString: @"%%APPNAME"
withString: appName
options: 0
range: NSMakeRange(0, [explanation length])];
[explanationField setStringValue: explanation];
// Insert user name and e-mail address into the information field:
NSMutableString* userMessage = nil;
Loading
Loading
@@ -354,4 +363,4 @@ NSString* gCrashLogString = nil;
[[UKCrashReporter alloc] init];
}
 
@end
\ No newline at end of file
@end
Loading
Loading
@@ -9,16 +9,16 @@
#import <Cocoa/Cocoa.h>
 
 
unsigned UKPhysicalRAMSize(); // RAM Size in MBs.
NSString* UKSystemVersionString(); // System version as a string MM.m.b
unsigned UKClockSpeed(); // CPU speed in MHz.
unsigned UKCountCores(); // Number of CPU cores. This is always >= number of CPUs.
NSString* UKMachineName(); // Name of Mac model, as best as we can determine.
NSString* UKCPUName(); // Same as UKAutoreleasedCPUName( NO );
unsigned UKPhysicalRAMSize(void); // RAM Size in MBs.
NSString* UKSystemVersionString(void); // System version as a string MM.m.b
unsigned UKClockSpeed(void); // CPU speed in MHz.
unsigned UKCountCores(void); // Number of CPU cores. This is always >= number of CPUs.
NSString* UKMachineName(void); // Name of Mac model, as best as we can determine.
NSString* UKCPUName(void); // Same as UKAutoreleasedCPUName( NO );
NSString* UKAutoreleasedCPUName( BOOL releaseIt ); // Returns CPU name, i.e. "G3", "G4" etc. If releaseIt is YES, this will look up the name anew each time, otherwise it will cache the name for subsequent calls. Doesn't support the G5 :-(
//NSString* UKSystemSerialNumber();
void UKGetSystemVersionComponents( long* outMajor, long* outMinor, long* outBugfix ); // System version as the separate components (Major.Minor.Bugfix).
void UKGetSystemVersionComponents( SInt32* outMajor, SInt32* outMinor, SInt32* outBugfix ); // System version as the separate components (Major.Minor.Bugfix).
 
// Don't use the following for new code:
// (Since the number is in BCD, the maximum for minor and bugfix revisions is 9, so this returns 1049 for 10.4.10)
long UKSystemVersion(); // System version as BCD number, I.e. 0xMMmb
unsigned int UKSystemVersion(void); // System version as BCD number, I.e. 0xMMmb
Loading
Loading
@@ -11,12 +11,12 @@
#include <sys/types.h>
#include <sys/sysctl.h>
 
unsigned UKPhysicalRAMSize()
unsigned int UKPhysicalRAMSize()
{
long ramSize;
SInt32 ramSize;
if( Gestalt( gestaltPhysicalRAMSizeInMegabytes, &ramSize ) == noErr )
return ramSize;
return (unsigned int)ramSize;
else
return 0;
}
Loading
Loading
@@ -24,14 +24,14 @@ unsigned UKPhysicalRAMSize()
 
NSString* UKSystemVersionString()
{
long vMajor = 10, vMinor = 0, vBugfix = 0;
SInt32 vMajor = 10, vMinor = 0, vBugfix = 0;
UKGetSystemVersionComponents( &vMajor, &vMinor, &vBugfix );
return [NSString stringWithFormat: @"%ld.%ld.%ld", vMajor, vMinor, vBugfix];
}
 
 
void UKGetSystemVersionComponents( long* outMajor, long* outMinor, long* outBugfix )
void UKGetSystemVersionComponents( SInt32* outMajor, SInt32* outMinor, SInt32* outBugfix )
{
long sysVersion = UKSystemVersion();
if( sysVersion >= MAC_OS_X_VERSION_10_4 )
Loading
Loading
@@ -42,32 +42,34 @@ void UKGetSystemVersionComponents( long* outMajor, long* outMinor, long* outBugf
}
else
{
*outMajor = ((sysVersion & 0x0000F000) >> 12) * 10 + ((sysVersion & 0x00000F00) >> 8);
*outMinor = (sysVersion & 0x000000F0) >> 4;
*outMajor = ((sysVersion & 0x0000F000) >> 12) * 10 + ((sysVersion & 0x00000F00) >> 8);
*outMinor = (sysVersion & 0x000000F0) >> 4;
*outBugfix = sysVersion & 0x0000000F;
}
}
 
 
long UKSystemVersion()
unsigned int UKSystemVersion()
{
long sysVersion = 0;
SInt32 sysVersion = 0;
if( Gestalt( gestaltSystemVersion, &sysVersion ) != noErr )
return 0;
return sysVersion;
return (unsigned int)sysVersion;
}
 
 
unsigned UKClockSpeed()
unsigned int UKClockSpeed()
{
long speed;
SInt32 speed;
if( Gestalt( gestaltProcClkSpeed, &speed ) == noErr )
return speed / 1000000;
else
if( Gestalt( gestaltProcClkSpeed, &speed ) == noErr ) {
speed = speed / 1000000;
return (unsigned int)speed;
} else {
return 0;
}
}
 
 
Loading
Loading
@@ -85,13 +87,13 @@ unsigned UKCountCores()
 
NSString* UKMachineName()
{
static NSString* cpuName = nil;
static NSString* cpuName = nil;
if( cpuName )
return cpuName;
char* machineName = NULL;
char* machineName = NULL;
if( Gestalt( gestaltUserVisibleMachineName, (long*) &machineName ) == noErr )
if( Gestalt( gestaltUserVisibleMachineName, (SInt32*) &machineName ) == noErr )
{
NSString* internalName = [NSString stringWithCString: machineName +1 length: machineName[0]];
Loading
Loading
@@ -177,7 +179,7 @@ NSString* UKMachineName()
NSEnumerator *e=[[[translationDictionary allKeys]
sortedArrayUsingSelector:@selector(compare:)]
objectEnumerator];
while( aKey = [e nextObject] )
while( (aKey = [e nextObject]) )
{
r = [internalName rangeOfString: aKey];
if( r.location != NSNotFound )
Loading
Loading
@@ -212,7 +214,7 @@ NSString* UKCPUName()
 
NSString* UKAutoreleasedCPUName( BOOL releaseIt )
{
long cpu;
SInt32 cpu;
static NSString* cpuName = nil;
if( Gestalt( gestaltNativeCPUtype, &cpu ) == noErr )
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment