Fix code review issues.

Signed-off-by: Ricky Zhang <rickyzhang@gmail.com>
This commit is contained in:
Ricky Zhang 2020-06-28 18:42:14 -04:00
parent e6cd178881
commit 8e88e462ee
No known key found for this signature in database
GPG Key ID: 681AFAEF6CDEDB4C
8 changed files with 15 additions and 152 deletions

View File

@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>BasiliskII</string>
<key>CFBundleGetInfoString</key>
<string>Basilisk II version 1.0, Copyright © 1997-2017 Christian Bauer et al. SDL2 port</string>
<string>Basilisk II version 1.0, Copyright © 1997-2020 Christian Bauer et al. SDL2 port</string>
<key>CFBundleIconFile</key>
<string>BasiliskII.icns</string>
<key>CFBundleIdentifier</key>

View File

@ -252,7 +252,8 @@ static int open_rsrc(const char *path, int flag)
make_rsrc_path(path, rsrc_path);
int fd = open(rsrc_path, flag);
if (fd < 0 && flag == O_WRONLY) fd = open(rsrc_path, O_WRONLY | O_CREAT); // for APFS
if (fd < 0 && flag == O_WRONLY)
fd = open(rsrc_path, O_WRONLY | O_CREAT); // for APFS
return fd;
}

View File

@ -1,136 +0,0 @@
/*
* runtool.m - Run an external program as root for networking
* Copyright (C) 2010, Daniel Sumorok
*
* Basilisk II (C) 1997-2008 Christian Bauer
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if_dl.h>
#include <ifaddrs.h>
#include <errno.h>
#include <unistd.h>
#include <net/if.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <net/bpf.h>
#include <fcntl.h>
#include <strings.h>
#include <Carbon/Carbon.h>
FILE * run_tool(const char *if_name, const char *tool_name);
FILE * run_tool(const char *if_name, const char *tool_name)
{
OSStatus auth_status;
FILE *fp = NULL;
char *args[] = {NULL, NULL, NULL};
int ret;
char path_buffer[256];
AuthorizationFlags auth_flags;
AuthorizationRef auth_ref;
AuthorizationItem auth_items[1];
AuthorizationRights auth_rights;
CFBundleRef bundle_ref;
CFURLRef url_ref;
CFStringRef path_str;
CFStringRef tool_name_str;
char c;
bundle_ref = CFBundleGetMainBundle();
if(bundle_ref == NULL) {
return NULL;
}
tool_name_str = CFStringCreateWithCString(NULL, tool_name,
kCFStringEncodingUTF8);
url_ref = CFBundleCopyResourceURL(bundle_ref, tool_name_str,
NULL, NULL);
CFRelease(tool_name_str);
if(url_ref == NULL) {
return NULL;
}
path_str = CFURLCopyFileSystemPath(url_ref, kCFURLPOSIXPathStyle);
CFRelease(url_ref);
if(path_str == NULL) {
return NULL;
}
if(!CFStringGetCString(path_str, path_buffer, sizeof(path_buffer),
kCFStringEncodingUTF8)) {
CFRelease(path_str);
return NULL;
}
CFRelease(path_str);
args[0] = (char *)tool_name;
args[1] = (char *)if_name;
auth_flags = kAuthorizationFlagExtendRights |
kAuthorizationFlagInteractionAllowed |
kAuthorizationFlagPreAuthorize;
auth_items[0].name = "system.privilege.admin";
auth_items[0].valueLength = 0;
auth_items[0].value = NULL;
auth_items[0].flags = 0;
auth_rights.count = sizeof (auth_items) / sizeof (auth_items[0]);
auth_rights.items = auth_items;
auth_status = AuthorizationCreate(&auth_rights,
kAuthorizationEmptyEnvironment,
auth_flags,
&auth_ref);
if (auth_status != errAuthorizationSuccess) {
fprintf(stderr, "%s: AuthorizationCreate() failed.\n",
__func__);
return NULL;
}
auth_status = AuthorizationExecuteWithPrivileges(auth_ref,
path_buffer,
kAuthorizationFlagDefaults,
args + 1,
&fp);
if (auth_status != errAuthorizationSuccess) {
fprintf(stderr, "%s: AuthorizationExecWithPrivileges() failed.\n",
__func__);
return NULL;
}
if(fread(&c, 1, 1, fp) != 1) {
fclose(fp);
return NULL;
}
return fp;
}

View File

@ -36,7 +36,6 @@ void NSAutoReleasePool_wrap(void (*fn)(void))
}
#if SDL_VERSION_ATLEAST(2,0,0)
void disable_SDL2_macosx_menu_bar_keyboard_shortcuts() {
for (NSMenuItem * menu_item in [NSApp mainMenu].itemArray) {
if (menu_item.hasSubmenu) {

View File

@ -2279,4 +2279,4 @@ void video_set_dirty_area(int x, int y, int w, int h)
// XXX handle dirty bounding boxes for non-VOSF modes
}
#endif
#endif //end of ifdef ENABLE_SDL1
#endif //ifdef ENABLE_SDL1

View File

@ -2720,4 +2720,4 @@ void video_set_dirty_area(int x, int y, int w, int h)
}
#endif
#endif // ends: ifdef ENABLE_SDL2
#endif //ifdef ENABLE_SDL2

View File

@ -456,17 +456,17 @@ int main(int argc, char **argv)
argv[i] = NULL;
}
#if defined(__APPLE__) && defined(__MACH__)
#if __MACOSX__
// Mac OS X likes to pass in various options of its own, when launching an app.
// Attempt to ignore these.
if (argv[i]) {
const char * mac_psn_prefix = "-psn_";
if (strcmp(argv[i], "-NSDocumentRevisionsDebugMode") == 0) {
argv[i] = NULL;
} else if (strncmp(mac_psn_prefix, argv[i], strlen(mac_psn_prefix)) == 0) {
argv[i] = NULL;
}
}
if (argv[i]) {
const char * mac_psn_prefix = "-psn_";
if (strcmp(argv[i], "-NSDocumentRevisionsDebugMode") == 0) {
argv[i] = NULL;
} else if (strncmp(mac_psn_prefix, argv[i], strlen(mac_psn_prefix)) == 0) {
argv[i] = NULL;
}
}
#endif
}

View File

@ -241,7 +241,6 @@ user_string_def common_strings[] = {
{STR_CPU_68040_LAB, "68040"},
{STR_ROM_FILE_CTRL, "ROM File"},
{STR_IDLEWAIT_CTRL, "Don't Use CPU When Idle"},
{STR_JIT_PANE_TITLE, "JIT Compiler"},
{STR_JIT_CTRL, "Enable JIT Compiler"},
{STR_JIT_FPU_CTRL, "Compile FPU Instructions"},
@ -258,7 +257,7 @@ user_string_def common_strings[] = {
{STR_WINDOW_TITLE_GRABBED, "Basilisk II (mouse grabbed, press Ctrl-F5 to release)"},
{STR_WINDOW_TITLE_GRABBED0, "Basilisk II (mouse grabbed, press "},
{STR_WINDOW_TITLE_GRABBED1, "Ctrl-"},
#ifdef __APPLE__
#ifdef __MACOSX__
{STR_WINDOW_TITLE_GRABBED2, "Opt-"},
{STR_WINDOW_TITLE_GRABBED3, "Cmd-"},
#else