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
This commit is contained in:
parent
e66ba25d49
commit
7c6a7978c0
|
@ -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;
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#import "RecentItemsMenu.h"
|
||||
|
||||
@class ConfigurationController;
|
||||
@class RecentItemsMenu;
|
||||
|
||||
@interface PcsxrController : NSObject <NSApplicationDelegate>
|
||||
{
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -33,4 +33,7 @@
|
|||
- (PcsxrPlugin *)activePluginForType:(int)type;
|
||||
- (BOOL)setActivePlugin:(PcsxrPlugin *)plugin forType:(int)type;
|
||||
|
||||
- (void)disableNetPlug;
|
||||
- (void)enableNetPlug;
|
||||
|
||||
@end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "PcsxrController.h"
|
||||
|
||||
@class PcsxrController;
|
||||
@interface RecentItemsMenu : NSMenu {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
//
|
||||
|
||||
#import "RecentItemsMenu.h"
|
||||
#import "PcsxrController.h"
|
||||
#import "ARCBridge.h"
|
||||
|
||||
@implementation RecentItemsMenu
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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; };
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue