Created
December 31, 2013 02:29
-
-
Save JRHeaton/8191589 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <CoreFoundation/CoreFoundation.h> | |
void xcselect_trigger_install_request(const char *str) { | |
CFMutableDictionaryRef options; | |
CFStringRef toolNameKey, toolName; | |
CFDataRef optionsData; | |
options = CFDictionaryCreateMutable(NULL, 0, NULL, NULL); | |
toolNameKey = CFStringCreateWithCString(NULL, "tool-name", kCFStringEncodingMacRoman); | |
toolName = CFStringCreateWithCString(NULL, str, kCFStringEncodingMacRoman); | |
CFDictionarySetValue(options, toolNameKey, toolName); | |
optionsData = CFPropertyListCreateData(NULL, (CFPropertyListRef)options, kCFPropertyListBinaryFormat_v1_0, 0, NULL); | |
CFRelease(toolNameKey); | |
CFRelease(toolName); | |
CFRelease(options); | |
if(optionsData) { | |
CFStringRef portName; | |
CFMessagePortRef port; | |
CFDataRef returnData; | |
portName = CFStringCreateWithCString(NULL, "com.apple.dt.CommandLineTools.installondemand", kCFStringEncodingMacRoman); | |
port = CFMessagePortCreateRemote(NULL, portName); | |
if(port) { | |
CFMessagePortSendRequest(port, 0, optionsData, 0, 0, NULL, &returnData); | |
} | |
} | |
} | |
int main(int argc, const char **argv) { | |
const char *name = "clinstall"; | |
if(argc > 1) | |
name = argv[1]; | |
xcselect_trigger_install_request(name); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment