summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2013-01-10 20:46:32 +0000
committerSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2013-01-10 20:46:32 +0000
commit7c6a7978c020b739e755c2bed56f91c5b7adf509 (patch)
tree618bfce436fcc3bb78722da2e7e2023616b0479f
parente66ba25d49a90a20e2465cadeef8e2e83ce291bc (diff)
downloadpcsxr-7c6a7978c020b739e755c2bed56f91c5b7adf509.tar.gz
Use strlcpy on OS X code.
> Better handling of the net system on OS X. git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@82182 e17a0e51-4ae3-4d35-97c3-1a29b211df97
-rwxr-xr-xmacosx/EmuThread.m2
-rwxr-xr-xmacosx/PcsxrController.h1
-rwxr-xr-xmacosx/PcsxrController.m61
-rwxr-xr-xmacosx/PcsxrPlugin.m20
-rwxr-xr-xmacosx/Plugin.c2
-rwxr-xr-xmacosx/PluginList.h3
-rwxr-xr-xmacosx/PluginList.m33
-rwxr-xr-xmacosx/RecentItemsMenu.h1
-rwxr-xr-xmacosx/RecentItemsMenu.m1
-rwxr-xr-xmacosx/main.m4
-rw-r--r--macosx/plugins/DFXVideo/PeopsSoftGPU.xcodeproj/project.pbxproj2
-rwxr-xr-xmacosx/plugins/DFXVideo/macsrc/PluginGLView.m2
12 files changed, 92 insertions, 40 deletions
diff --git a/macosx/EmuThread.m b/macosx/EmuThread.m
index ceeeb486..fa062366 100755
--- a/macosx/EmuThread.m
+++ b/macosx/EmuThread.m
@@ -80,6 +80,7 @@ static NSString * const ThreadInfo = @"PSX Emu Background thread";
psxCpu->Execute();
done:
+ AUTORELEASEOBJNORETURN(emuThread);
emuThread = nil;
return;
@@ -115,6 +116,7 @@ static NSString * const ThreadInfo = @"PSX Emu Background thread";
psxCpu->Execute();
done:
+ AUTORELEASEOBJNORETURN(emuThread);
emuThread = nil;
return;
diff --git a/macosx/PcsxrController.h b/macosx/PcsxrController.h
index 70f88e81..a6bed84f 100755
--- a/macosx/PcsxrController.h
+++ b/macosx/PcsxrController.h
@@ -6,7 +6,6 @@
#import "RecentItemsMenu.h"
@class ConfigurationController;
-@class RecentItemsMenu;
@interface PcsxrController : NSObject <NSApplicationDelegate>
{
diff --git a/macosx/PcsxrController.m b/macosx/PcsxrController.m
index 5949adcf..d823a852 100755
--- a/macosx/PcsxrController.m
+++ b/macosx/PcsxrController.m
@@ -6,6 +6,7 @@
#import "PcsxrPluginHandler.h"
#import "PcsxrDiscHandler.h"
#import "PcsxrFreezeStateHandler.h"
+#import "PluginList.h"
#include "psxcommon.h"
#include "plugins.h"
#include "misc.h"
@@ -109,6 +110,11 @@ NSString *saveStatePath;
- (IBAction)runCD:(id)sender
{
SetIsoFile(NULL);
+ if ([[NSUserDefaults standardUserDefaults] boolForKey:@"NetPlay"]) {
+ [[PluginList list] enableNetPlug];
+ } else {
+ [[PluginList list] disableNetPlug];
+ }
[EmuThread run];
}
@@ -131,6 +137,7 @@ NSString *saveStatePath;
- (IBAction)runBios:(id)sender
{
SetIsoFile(NULL);
+ [[PluginList list] disableNetPlug];
[EmuThread runBios];
}
@@ -140,6 +147,11 @@ NSString *saveStatePath;
SetCdOpenCaseTime(time(NULL) + 2);
SetIsoFile([[url path] fileSystemRepresentation]);
} else {
+ if ([[NSUserDefaults standardUserDefaults] boolForKey:@"NetPlay"]) {
+ [[PluginList list] enableNetPlug];
+ } else {
+ [[PluginList list] disableNetPlug];
+ }
SetIsoFile((const char *)[[url path] fileSystemRepresentation]);
[EmuThread run];
}
@@ -277,7 +289,6 @@ NSString *saveStatePath;
{
NSEnumerator *enumerator;
const char *str;
- NSString *key;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
/*
@@ -288,8 +299,7 @@ NSString *saveStatePath;
if (str != nil && dst != nil) strncpy(dst, str, 255);
}*/
- enumerator = [prefByteKeys keyEnumerator];
- while ((key = [enumerator nextObject])) {
+ for (NSString *key in prefByteKeys) {
u8 *dst = (u8 *)[[prefByteKeys objectForKey:key] pointerValue];
if (dst != nil) *dst = [defaults integerForKey:key];
}
@@ -311,21 +321,21 @@ NSString *saveStatePath;
}
str = [[defaults stringForKey:@"Mcd1"] fileSystemRepresentation];
- if (str) strncpy(Config.Mcd1, str, MAXPATHLEN);
+ if (str) strlcpy(Config.Mcd1, str, MAXPATHLEN);
str = [[defaults stringForKey:@"Mcd2"] fileSystemRepresentation];
- if (str) strncpy(Config.Mcd2, str, MAXPATHLEN);
+ if (str) strlcpy(Config.Mcd2, str, MAXPATHLEN);
if ([defaults boolForKey:@"UseHLE"] || 0 == [biosList count]) {
strcpy(Config.Bios, "HLE");
} else {
str = [(NSString *)[biosList objectAtIndex:0] fileSystemRepresentation];
- if (str != nil) strncpy(Config.Bios, str, MAXPATHLEN);
+ if (str != nil) strlcpy(Config.Bios, str, MAXPATHLEN);
else strcpy(Config.Bios, "HLE");
}
str = [[defaults stringForKey:@"Net"] fileSystemRepresentation];
- if (str) strncpy(Config.Net, str, MAXPATHLEN);
+ if (str) strlcpy(Config.Net, str, MAXPATHLEN);
else {
strcpy(Config.Net, "Disabled");
}
@@ -360,13 +370,14 @@ NSString *saveStatePath;
const char *str;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithBool:YES], @"NoDynarec",
- [NSNumber numberWithBool:YES], @"AutoDetectVideoType",
- [NSNumber numberWithBool:NO], @"UseHLE",
- [NSNumber numberWithBool:YES], @"PauseInBackground",
- [NSNumber numberWithBool:NO], @"Widescreen",
- nil];
-
+ [NSNumber numberWithBool:YES], @"NoDynarec",
+ [NSNumber numberWithBool:YES], @"AutoDetectVideoType",
+ [NSNumber numberWithBool:NO], @"UseHLE",
+ [NSNumber numberWithBool:YES], @"PauseInBackground",
+ [NSNumber numberWithBool:NO], @"Widescreen",
+ [NSNumber numberWithBool:NO], @"NetPlay",
+ nil];
+
[defaults registerDefaults:appDefaults];
prefStringKeys = [[NSDictionary alloc] initWithObjectsAndKeys:
@@ -381,7 +392,7 @@ NSString *saveStatePath;
prefByteKeys = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSValue valueWithPointer:&Config.Xa], @"NoXaAudio",
- [NSValue valueWithPointer:&Config.UseNet], @"NetPlay",
+ //[NSValue valueWithPointer:&Config.UseNet], @"NetPlay",
[NSValue valueWithPointer:&Config.Sio], @"SioIrqAlways",
[NSValue valueWithPointer:&Config.Mdec], @"BlackAndWhiteMDECVideo",
[NSValue valueWithPointer:&Config.PsxAuto], @"AutoDetectVideoType",
@@ -431,19 +442,23 @@ NSString *saveStatePath;
url = [MemCardPath URLByAppendingPathComponent:@"Mcd001.mcr"];
str = [[url path] fileSystemRepresentation];
- if (str != nil) strncpy(Config.Mcd1, str, MAXPATHLEN);
+ if (str != nil) strlcpy(Config.Mcd1, str, MAXPATHLEN);
url = [MemCardPath URLByAppendingPathComponent:@"Mcd002.mcr"];
str = [[url path] fileSystemRepresentation];
- if (str != nil) strncpy(Config.Mcd2, str, MAXPATHLEN);
+ if (str != nil) strlcpy(Config.Mcd2, str, MAXPATHLEN);
url = [PcsxrAppSupport URLByAppendingPathComponent:@"Bios"];
str = [[url path] fileSystemRepresentation];
- if (str != nil) strncpy(Config.BiosDir, str, MAXPATHLEN);
+ if (str != nil) strlcpy(Config.BiosDir, str, MAXPATHLEN);
url = [PcsxrAppSupport URLByAppendingPathComponent:@"Patches"];
str = [[url path] fileSystemRepresentation];
- if (str != nil) strncpy(Config.PatchesDir, str, MAXPATHLEN);
+ if (str != nil) {
+ strlcpy(Config.PatchesDir, str, MAXPATHLEN);
+ //workaround for the fact that the PCSXR core doesn't append a forward slash to the patches dir
+ strlcat(Config.PatchesDir, "/", MAXPATHLEN);
+ }
} else {
strcpy(Config.BiosDir, "Bios/");
strcpy(Config.PatchesDir, "Patches/");
@@ -454,7 +469,7 @@ NSString *saveStatePath;
// set plugin path
path = [[NSBundle mainBundle] builtInPlugInsPath];
str = [path fileSystemRepresentation];
- if (str != nil) strncpy(Config.PluginsDir, str, MAXPATHLEN);
+ if (str != nil) strlcpy(Config.PluginsDir, str, MAXPATHLEN);
// locate a bios
biosList = [[NSMutableArray alloc] init];
@@ -462,14 +477,12 @@ NSString *saveStatePath;
NSString *biosDir = [manager stringWithFileSystemRepresentation:Config.BiosDir length:strlen(Config.BiosDir)];
NSArray *bioses = [manager contentsOfDirectoryAtPath:biosDir error:NULL];
if (bioses) {
- NSUInteger i;
- for (i = 0; i < [bioses count]; i++) {
- NSString *file = [bioses objectAtIndex:i];
+ for (NSString *file in bioses) {
NSDictionary *attrib = [manager attributesOfItemAtPath:[[biosDir stringByAppendingPathComponent:file] stringByResolvingSymlinksInPath] error:NULL];
if ([[attrib fileType] isEqualToString:NSFileTypeRegular]) {
unsigned long long size = [attrib fileSize];
- if (([attrib fileSize] % (256 * 1024)) == 0 && size > 0) {
+ if ((size % (256 * 1024)) == 0 && size > 0) {
[biosList addObject:file];
}
}
diff --git a/macosx/PcsxrPlugin.m b/macosx/PcsxrPlugin.m
index b311c503..46fdaa0b 100755
--- a/macosx/PcsxrPlugin.m
+++ b/macosx/PcsxrPlugin.m
@@ -17,11 +17,11 @@
+ (NSString *)prefixForType:(int)aType
{
switch (aType) {
- case PSE_LT_GPU: return @"GPU";
- case PSE_LT_CDR: return @"CDR";
- case PSE_LT_SPU: return @"SPU";
- case PSE_LT_PAD: return @"PAD";
- case PSE_LT_NET: return @"NET";
+ case PSE_LT_GPU: return @"GPU"; break;
+ case PSE_LT_CDR: return @"CDR"; break;
+ case PSE_LT_SPU: return @"SPU"; break;
+ case PSE_LT_PAD: return @"PAD"; break;
+ case PSE_LT_NET: return @"NET"; break;
}
return @"";
@@ -127,7 +127,7 @@
if (SysLibError() == NULL)
{
long tempVers2 = tempLibVersion();
- if (tempVers <= tempVers2 ){
+ if (tempVers < tempVers2 ){
goodPath = fullPath;
tempVers = tempVers2;
if (![plugDir isEqualToString:[fm stringWithFileSystemRepresentation:Config.PluginsDir length:strlen(Config.PluginsDir)]]) {
@@ -364,6 +364,14 @@
return [NSString stringWithFormat:@"%@ %@ [%@]", name, [self displayVersion], [path lastPathComponent]];
}
+- (NSString*)debugDescription
+{
+ if (name == nil) {
+ return fullPlugPath;
+ }
+ return [NSString stringWithFormat:@"%@ %@ [%@]", name, [self displayVersion], fullPlugPath];
+}
+
// the plugin will check if it's still valid and return the status
- (BOOL)verifyOK
{
diff --git a/macosx/Plugin.c b/macosx/Plugin.c
index 02951613..691af379 100755
--- a/macosx/Plugin.c
+++ b/macosx/Plugin.c
@@ -95,7 +95,7 @@ int _OpenPlugins() {
strcpy(info.EmuName, "PCSX " PACKAGE_VERSION);
strncpy(info.CdromID, CdromId, 9);
- strncpy(info.CdromLabel, CdromLabel, 9);
+ strncpy(info.CdromLabel, CdromLabel, 11);
info.psxMem = psxM;
info.GPU_showScreenPic = GPU_showScreenPic;
info.GPU_displayText = GPU_displayText;
diff --git a/macosx/PluginList.h b/macosx/PluginList.h
index 8eaa6727..9e6107d0 100755
--- a/macosx/PluginList.h
+++ b/macosx/PluginList.h
@@ -33,4 +33,7 @@
- (PcsxrPlugin *)activePluginForType:(int)type;
- (BOOL)setActivePlugin:(PcsxrPlugin *)plugin forType:(int)type;
+- (void)disableNetPlug;
+- (void)enableNetPlug;
+
@end
diff --git a/macosx/PluginList.m b/macosx/PluginList.m
index 12c1054b..6fa341d9 100755
--- a/macosx/PluginList.m
+++ b/macosx/PluginList.m
@@ -101,7 +101,7 @@ const static int typeList[5] = {PSE_LT_GPU, PSE_LT_SPU, PSE_LT_CDR, PSE_LT_PAD,
activeGpuPlugin = activeSpuPlugin = activeCdrPlugin = activePadPlugin = activeNetPlugin = nil;
missingPlugins = NO;
- for (i = 0; i < sizeof(*typeList); i++) {
+ for (i = 0; i < sizeof(typeList) / sizeof(typeList[0]); i++) {
NSString *path = [defaults stringForKey:[PcsxrPlugin defaultKeyForType:typeList[i]]];
if (nil == path) {
missingPlugins = YES;
@@ -121,7 +121,7 @@ const static int typeList[5] = {PSE_LT_GPU, PSE_LT_SPU, PSE_LT_CDR, PSE_LT_PAD,
}
}
}
-
+
if (missingPlugins) {
[self refreshPlugins];
}
@@ -314,7 +314,7 @@ const static int typeList[5] = {PSE_LT_GPU, PSE_LT_SPU, PSE_LT_CDR, PSE_LT_PAD,
const char *str;
if (plugin != nil) {
str = [[plugin path] fileSystemRepresentation];
- if (str == nil) {
+ if (str == NULL) {
str = "Invalid Plugin";
}
} else {
@@ -339,4 +339,31 @@ const static int typeList[5] = {PSE_LT_GPU, PSE_LT_SPU, PSE_LT_CDR, PSE_LT_PAD,
return plugin != nil;
}
+- (void)disableNetPlug
+{
+ char **dst = [PcsxrPlugin configEntriesForType:PSE_LT_NET];
+ while (*dst) {
+ strcpy(*dst, "Disabled");
+ dst++;
+ }
+}
+
+- (void)enableNetPlug
+{
+ PcsxrPlugin *netPlug = [self activePluginForType:PSE_LT_NET];
+
+ const char *str = NULL;
+ if (netPlug) {
+ str = [[netPlug path] fileSystemRepresentation];
+ }
+ if (str) {
+ char **dst = [PcsxrPlugin configEntriesForType:PSE_LT_NET];
+ while (*dst) {
+ strlcpy(*dst, str, MAXPATHLEN);
+ dst++;
+ }
+ }
+
+}
+
@end
diff --git a/macosx/RecentItemsMenu.h b/macosx/RecentItemsMenu.h
index 21c518c8..220380c0 100755
--- a/macosx/RecentItemsMenu.h
+++ b/macosx/RecentItemsMenu.h
@@ -7,7 +7,6 @@
//
#import <Cocoa/Cocoa.h>
-#import "PcsxrController.h"
@class PcsxrController;
@interface RecentItemsMenu : NSMenu {
diff --git a/macosx/RecentItemsMenu.m b/macosx/RecentItemsMenu.m
index a3ffa8ee..d50abeff 100755
--- a/macosx/RecentItemsMenu.m
+++ b/macosx/RecentItemsMenu.m
@@ -7,6 +7,7 @@
//
#import "RecentItemsMenu.h"
+#import "PcsxrController.h"
#import "ARCBridge.h"
@implementation RecentItemsMenu
diff --git a/macosx/main.m b/macosx/main.m
index aeac823a..8c5beb73 100755
--- a/macosx/main.m
+++ b/macosx/main.m
@@ -26,7 +26,7 @@ int main(int argc, const char *argv[]) {
char parentdir[MAXPATHLEN];
char *c;
- strncpy ( parentdir, argv[0], sizeof(parentdir) );
+ strlcpy ( parentdir, argv[0], sizeof(parentdir) );
c = (char*) parentdir;
while (*c != '\0') /* go to end */
@@ -74,7 +74,7 @@ int SysInit() {
LoadMcds(Config.Mcd1, Config.Mcd2);
- IOReturn success= IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, CFSTR("PSX Emu Running"), &powerAssertion);
+ IOReturn success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, CFSTR("PSX Emu Running"), &powerAssertion);
if (success != kIOReturnSuccess) {
NSLog(@"Unable to stop sleep, error code %d", success);
}
diff --git a/macosx/plugins/DFXVideo/PeopsSoftGPU.xcodeproj/project.pbxproj b/macosx/plugins/DFXVideo/PeopsSoftGPU.xcodeproj/project.pbxproj
index ef3974da..733fe643 100644
--- a/macosx/plugins/DFXVideo/PeopsSoftGPU.xcodeproj/project.pbxproj
+++ b/macosx/plugins/DFXVideo/PeopsSoftGPU.xcodeproj/project.pbxproj
@@ -58,7 +58,7 @@
71E9EBF3109F24E600E98D1D /* externals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = externals.h; path = ../../../plugins/dfxvideo/externals.h; sourceTree = SOURCE_ROOT; };
71E9EBF4109F24E600E98D1D /* fps.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = fps.c; path = ../../../plugins/dfxvideo/fps.c; sourceTree = SOURCE_ROOT; };
71E9EBF5109F24E600E98D1D /* fps.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = fps.h; path = ../../../plugins/dfxvideo/fps.h; sourceTree = SOURCE_ROOT; };
- 71E9EBF6109F24E600E98D1D /* gpu.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = gpu.c; path = ../../../plugins/dfxvideo/gpu.c; sourceTree = SOURCE_ROOT; };
+ 71E9EBF6109F24E600E98D1D /* gpu.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 1; lastKnownFileType = sourcecode.c.c; name = gpu.c; path = ../../../plugins/dfxvideo/gpu.c; sourceTree = SOURCE_ROOT; usesTabs = 0; };
71E9EBF7109F24E600E98D1D /* gpu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = gpu.h; path = ../../../plugins/dfxvideo/gpu.h; sourceTree = SOURCE_ROOT; };
71E9EBF8109F24E600E98D1D /* interp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = interp.h; path = ../../../plugins/dfxvideo/interp.h; sourceTree = SOURCE_ROOT; };
71E9EBF9109F24E600E98D1D /* key.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = key.c; path = ../../../plugins/dfxvideo/key.c; sourceTree = SOURCE_ROOT; };
diff --git a/macosx/plugins/DFXVideo/macsrc/PluginGLView.m b/macosx/plugins/DFXVideo/macsrc/PluginGLView.m
index 8f6f3802..ecfc25e8 100755
--- a/macosx/plugins/DFXVideo/macsrc/PluginGLView.m
+++ b/macosx/plugins/DFXVideo/macsrc/PluginGLView.m
@@ -418,7 +418,7 @@ void BlitScreen16NS(unsigned char * surf,long x,long y)
int len, i;
if(szDebugText[0] && ((time(NULL) - tStart) < 2))
{
- strncpy(szDispBuf, szDebugText, 63);
+ strlcpy(szDispBuf, szDebugText, 63);
}
else
{