DiskArbitrationAgent.c [plain text]
#include "../diskarbitrationd/DAInternal.h"
#include <xpc/private.h>
#include <ApplicationServices/ApplicationServices.h>
static void __DAAgentMessageCallback( xpc_object_t object );
static void __DAAgentConnectionCallback( xpc_object_t object )
{
xpc_type_t type;
type = xpc_get_type( object );
if ( type == XPC_TYPE_CONNECTION )
{
xpc_connection_set_event_handler( object, ^( xpc_object_t object ) { __DAAgentMessageCallback( object ); } );
xpc_connection_resume( object );
}
}
static void __DAAgentMessageCallback( xpc_object_t object )
{
xpc_type_t type;
type = xpc_get_type( object );
if ( type == XPC_TYPE_DICTIONARY )
{
CFURLRef path;
path = CFURLCreateWithFileSystemPath( kCFAllocatorDefault, CFSTR( "/Applications/Utilities/Disk Utility.app" ), kCFURLPOSIXPathStyle, FALSE );
if ( path )
{
LSOpenCFURLRef( path, NULL );
CFRelease( path );
}
}
exit( 0 );
}
int main( )
{
xpc_connection_t connection;
connection = xpc_connection_create_listener( _kDAAgentName, NULL );
if ( connection )
{
xpc_connection_set_event_handler( connection, ^( xpc_object_t object ) { __DAAgentConnectionCallback( object ); } );
xpc_connection_set_legacy( connection );
xpc_connection_resume( connection );
dispatch_main( );
xpc_release( connection );
}
return 0;
}