mirror of
https://github.com/kanjitalk755/macemu.git
synced 2025-02-17 06:31:14 +00:00
Removed objective-c from runtool source so it can be built with
newer (not from Apple) versions of gcc.
This commit is contained in:
parent
531b1d7df4
commit
c939be2d2d
@ -40,28 +40,56 @@
|
|||||||
|
|
||||||
#include <Carbon/Carbon.h>
|
#include <Carbon/Carbon.h>
|
||||||
|
|
||||||
FILE * run_tool(const char *ifName);
|
FILE * run_tool(const char *if_name, const char *tool_name);
|
||||||
|
|
||||||
FILE * run_tool(const char *ifName)
|
FILE * run_tool(const char *if_name, const char *tool_name)
|
||||||
{
|
{
|
||||||
OSStatus auth_status;
|
OSStatus auth_status;
|
||||||
FILE *fp;
|
FILE *fp = NULL;
|
||||||
char *args[] = {"etherslavetool", NULL, NULL};
|
char *args[] = {"etherslavetool", NULL, NULL};
|
||||||
int ret;
|
int ret;
|
||||||
const char *path;
|
char path_buffer[256];
|
||||||
AuthorizationFlags auth_flags;
|
AuthorizationFlags auth_flags;
|
||||||
AuthorizationRef auth_ref;
|
AuthorizationRef auth_ref;
|
||||||
AuthorizationItem auth_items[1];
|
AuthorizationItem auth_items[1];
|
||||||
AuthorizationRights auth_rights;
|
AuthorizationRights auth_rights;
|
||||||
|
CFBundleRef bundle_ref;
|
||||||
|
CFURLRef url_ref;
|
||||||
|
CFStringRef path_str;
|
||||||
|
CFStringRef tool_name_str;
|
||||||
|
|
||||||
path = [[[NSBundle mainBundle]
|
bundle_ref = CFBundleGetMainBundle();
|
||||||
pathForResource:@"etherslavetool" ofType: nil] UTF8String];
|
if(bundle_ref == NULL) {
|
||||||
|
|
||||||
if (path == NULL) {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
args[1] = (char *)ifName;
|
tool_name_str = CFStringCreateWithCString(NULL, tool_name,
|
||||||
|
kCFStringEncodingUTF8);
|
||||||
|
|
||||||
|
url_ref = CFBundleCopyResourceURL(bundle_ref, tool_name_str,
|
||||||
|
NULL, NULL);
|
||||||
|
|
||||||
|
if(url_ref == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
path_str = CFURLCopyFileSystemPath(url_ref, kCFURLPOSIXPathStyle);
|
||||||
|
CFRelease(url_ref);
|
||||||
|
|
||||||
|
if(path_str == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
CFIndex index = CFStringGetLength(path_str);
|
||||||
|
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 |
|
auth_flags = kAuthorizationFlagExtendRights |
|
||||||
kAuthorizationFlagInteractionAllowed |
|
kAuthorizationFlagInteractionAllowed |
|
||||||
@ -81,18 +109,20 @@ FILE * run_tool(const char *ifName)
|
|||||||
&auth_ref);
|
&auth_ref);
|
||||||
|
|
||||||
if (auth_status != errAuthorizationSuccess) {
|
if (auth_status != errAuthorizationSuccess) {
|
||||||
fprintf(stderr, "%s: AuthorizationCreate() failed.\n", __func__);
|
fprintf(stderr, "%s: AuthorizationCreate() failed.\n",
|
||||||
|
__func__);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
auth_status = AuthorizationExecuteWithPrivileges(auth_ref,
|
auth_status = AuthorizationExecuteWithPrivileges(auth_ref,
|
||||||
path,
|
path_buffer,
|
||||||
kAuthorizationFlagDefaults,
|
kAuthorizationFlagDefaults,
|
||||||
args + 1,
|
args + 1,
|
||||||
&fp);
|
&fp);
|
||||||
|
|
||||||
if (auth_status != errAuthorizationSuccess) {
|
if (auth_status != errAuthorizationSuccess) {
|
||||||
fprintf(stderr, "%s: AuthorizationExecWithPrivileges() failed.\n", __func__);
|
fprintf(stderr, "%s: AuthorizationExecWithPrivileges() failed.\n",
|
||||||
|
__func__);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -736,7 +736,7 @@ if [[ "x$WANT_MACOSX_SOUND" = "xyes" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "x$WANT_MACOSX_ETHERSLAVE" = "xyes" ]]; then
|
if [[ "x$WANT_MACOSX_ETHERSLAVE" = "xyes" ]]; then
|
||||||
EXTRASYSSRCS="$EXTRASYSSRCS ../MacOSX/runtool.m"
|
EXTRASYSSRCS="$EXTRASYSSRCS ../MacOSX/runtool.c"
|
||||||
LIBS="$LIBS -framework Security"
|
LIBS="$LIBS -framework Security"
|
||||||
AC_DEFINE(ENABLE_MACOSX_ETHERSLAVE, 1, [Define if supporting "etherslave" network device.])
|
AC_DEFINE(ENABLE_MACOSX_ETHERSLAVE, 1, [Define if supporting "etherslave" network device.])
|
||||||
fi
|
fi
|
||||||
|
@ -106,7 +106,7 @@ enum {
|
|||||||
|
|
||||||
#ifdef ENABLE_MACOSX_ETHERSLAVE
|
#ifdef ENABLE_MACOSX_ETHERSLAVE
|
||||||
extern "C" {
|
extern "C" {
|
||||||
extern FILE * run_tool(const char *if_name);
|
extern FILE * run_tool(const char *if_name, const char *tool_name);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1168,7 +1168,7 @@ static bool open_ether_slave(const char *if_name)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fp = run_tool(if_name);
|
fp = run_tool(if_name, "etherslavetool");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
snprintf(str, sizeof(str), "Unable to run ether slave helper tool.");
|
snprintf(str, sizeof(str), "Unable to run ether slave helper tool.");
|
||||||
WarningAlert(str);
|
WarningAlert(str);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user